uniqueui-cli 0.1.2 → 0.1.4
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 +31 -4
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/commands/add.js
CHANGED
|
@@ -23,16 +23,43 @@ 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 {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
26
39
|
try {
|
|
27
40
|
// For local testing, if url is a file path, read it
|
|
28
41
|
if (options.url.startsWith(".")) {
|
|
29
42
|
registry = await fs_extra_1.default.readJson(options.url);
|
|
30
43
|
}
|
|
31
44
|
else {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
45
|
+
// Try primary URL first
|
|
46
|
+
let result = await fetchRegistryFromUrl(options.url);
|
|
47
|
+
// Try /api/registry endpoint as alternative
|
|
48
|
+
if (!result) {
|
|
49
|
+
console.log(chalk_1.default.yellow(`Could not fetch from ${options.url}/registry.json, trying API endpoint...`));
|
|
50
|
+
result = await fetchRegistryFromUrl(`${options.url}/api/registry`);
|
|
51
|
+
}
|
|
52
|
+
// Try fallback GitHub raw URL
|
|
53
|
+
if (!result && options.url !== FALLBACK_URL) {
|
|
54
|
+
console.log(chalk_1.default.yellow(`Trying fallback URL: ${FALLBACK_URL}...`));
|
|
55
|
+
result = await fetchRegistryFromUrl(FALLBACK_URL);
|
|
56
|
+
}
|
|
57
|
+
if (!result) {
|
|
58
|
+
throw new Error(`Failed to fetch registry from ${options.url}.\n` +
|
|
59
|
+
` Make sure the registry URL is accessible.\n` +
|
|
60
|
+
` You can specify a custom URL with: uniqueui add <component> --url <url>`);
|
|
61
|
+
}
|
|
62
|
+
registry = result;
|
|
36
63
|
}
|
|
37
64
|
}
|
|
38
65
|
catch (e) {
|
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();
|