uniqueui-cli 0.1.3 → 0.1.6
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 +57 -5
- package/dist/debug.js +37 -0
- package/dist/index.js +2 -2
- package/package.json +9 -8
package/dist/commands/add.js
CHANGED
|
@@ -23,16 +23,44 @@ async function add(componentName, options) {
|
|
|
23
23
|
}
|
|
24
24
|
// 2. Fetch registry
|
|
25
25
|
let registry;
|
|
26
|
+
const FALLBACK_URL = "https://raw.githubusercontent.com/pras75299/uniqueui/main";
|
|
27
|
+
async function fetchRegistryFromUrl(baseUrl) {
|
|
28
|
+
try {
|
|
29
|
+
const registryUrl = baseUrl.endsWith('.json') ? baseUrl : `${baseUrl}/registry.json`;
|
|
30
|
+
const res = await (0, node_fetch_1.default)(registryUrl);
|
|
31
|
+
if (!res.ok)
|
|
32
|
+
return null;
|
|
33
|
+
return await res.json();
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error(chalk_1.default.yellow(`\nWarning: Failed to fetch from ${baseUrl}:`), error);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
26
40
|
try {
|
|
27
41
|
// For local testing, if url is a file path, read it
|
|
28
42
|
if (options.url.startsWith(".")) {
|
|
29
43
|
registry = await fs_extra_1.default.readJson(options.url);
|
|
30
44
|
}
|
|
31
45
|
else {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
46
|
+
// Try primary URL first
|
|
47
|
+
let result = await fetchRegistryFromUrl(options.url);
|
|
48
|
+
// Try /api/registry endpoint as alternative
|
|
49
|
+
if (!result) {
|
|
50
|
+
console.log(chalk_1.default.yellow(`Could not fetch from ${options.url}/registry.json, trying API endpoint...`));
|
|
51
|
+
result = await fetchRegistryFromUrl(`${options.url}/api/registry`);
|
|
52
|
+
}
|
|
53
|
+
// Try fallback GitHub raw URL
|
|
54
|
+
if (!result && options.url !== FALLBACK_URL) {
|
|
55
|
+
console.log(chalk_1.default.yellow(`Trying fallback URL: ${FALLBACK_URL}...`));
|
|
56
|
+
result = await fetchRegistryFromUrl(FALLBACK_URL);
|
|
57
|
+
}
|
|
58
|
+
if (!result) {
|
|
59
|
+
throw new Error(`Failed to fetch registry from ${options.url}.\n` +
|
|
60
|
+
` Make sure the registry URL is accessible.\n` +
|
|
61
|
+
` You can specify a custom URL with: uniqueui add <component> --url <url>`);
|
|
62
|
+
}
|
|
63
|
+
registry = result;
|
|
36
64
|
}
|
|
37
65
|
}
|
|
38
66
|
catch (e) {
|
|
@@ -77,13 +105,37 @@ async function add(componentName, options) {
|
|
|
77
105
|
}
|
|
78
106
|
}
|
|
79
107
|
async function updateTailwindConfig(configPath, newConfig) {
|
|
108
|
+
// Check for config file existence and handle fallback
|
|
109
|
+
let finalConfigPath = configPath;
|
|
110
|
+
if (!fs_extra_1.default.existsSync(finalConfigPath)) {
|
|
111
|
+
// Try alternatives
|
|
112
|
+
const ext = path_1.default.extname(configPath);
|
|
113
|
+
const base = configPath.slice(0, -ext.length);
|
|
114
|
+
const altExts = [".ts", ".js", ".mjs", ".cjs"];
|
|
115
|
+
const found = altExts.find(e => fs_extra_1.default.existsSync(base + e));
|
|
116
|
+
if (found) {
|
|
117
|
+
console.log(chalk_1.default.yellow(`Config ${configPath} not found, using ${base + found} instead.`));
|
|
118
|
+
finalConfigPath = base + found;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
console.warn(chalk_1.default.yellow(`Tailwind config not found at ${configPath}. Skipping update.`));
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
80
125
|
const project = new ts_morph_1.Project({
|
|
81
126
|
manipulationSettings: {
|
|
82
127
|
quoteKind: ts_morph_1.QuoteKind.Double,
|
|
83
128
|
}
|
|
84
129
|
});
|
|
85
130
|
// Attempt to add the file
|
|
86
|
-
|
|
131
|
+
let sourceFile;
|
|
132
|
+
try {
|
|
133
|
+
sourceFile = project.addSourceFileAtPath(finalConfigPath);
|
|
134
|
+
}
|
|
135
|
+
catch (e) {
|
|
136
|
+
console.error(chalk_1.default.yellow(`Failed to parse tailwind config at ${finalConfigPath}. Skipping update.`), e);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
87
139
|
// Simplistic handling: look for export default or module.exports
|
|
88
140
|
// We expect the config to be an object literal.
|
|
89
141
|
// We need to merge `newConfig.theme.extend` into the existing config.
|
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/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const program = new commander_1.Command();
|
|
|
8
8
|
program
|
|
9
9
|
.name("uniqueui")
|
|
10
10
|
.description("Add components from UniqueUI to your project")
|
|
11
|
-
.version("0.1.
|
|
11
|
+
.version("0.1.4");
|
|
12
12
|
program
|
|
13
13
|
.command("init")
|
|
14
14
|
.description("Configure your project for UniqueUI")
|
|
@@ -17,6 +17,6 @@ program
|
|
|
17
17
|
.command("add")
|
|
18
18
|
.description("Add a component to your project")
|
|
19
19
|
.argument("<component>", "the component to add")
|
|
20
|
-
.option("--url <url>", "the base URL of the registry", "https://
|
|
20
|
+
.option("--url <url>", "the base URL of the registry", "https://uniqueui-platform.vercel.app")
|
|
21
21
|
.action(add_1.add);
|
|
22
22
|
program.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uniqueui-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
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
|
}
|