theflowui 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.
Files changed (2) hide show
  1. package/index.js +75 -0
  2. package/package.json +31 -0
package/index.js ADDED
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { program } from "commander";
4
+ import axios from "axios";
5
+ import fs from "fs-extra";
6
+ import path from "path";
7
+ import { exec } from "child_process";
8
+ import util from "util";
9
+
10
+ const execPromise = util.promisify(exec);
11
+
12
+ const FLOWUI_REPO_RAW_BASE = "https://raw.githubusercontent.com/KushalXCoder/flowui/main/";
13
+ const REGISTRY_URL = `${FLOWUI_REPO_RAW_BASE}public/flow/registry.json`;
14
+
15
+ program
16
+ .name("theflowui")
17
+ .description("This is the official CLI for the FlowUI library.")
18
+ .version("1.0.0");
19
+
20
+ program
21
+ .command("add <components...>")
22
+ .description("Add one or more FlowUI components to your project")
23
+ .action(async (components) => {
24
+ try {
25
+ console.log("Fetching registry...");
26
+ const { data: registry } = await axios.get(REGISTRY_URL);
27
+
28
+ // Ensure components folder exists in user's project
29
+ const targetDir = path.join(process.cwd(), "components/flowui");
30
+ await fs.ensureDir(targetDir);
31
+
32
+ for (const compName of components) {
33
+ const comp = registry.items.find(c => c.name === compName);
34
+ if (!comp) {
35
+ console.log(`Component "${compName}" not found in registry.`);
36
+ continue;
37
+ }
38
+
39
+ const filePath = comp.files.path || comp.path;
40
+ const type = "tsx";
41
+
42
+ const url = `${FLOWUI_REPO_RAW_BASE}${filePath}`;
43
+ console.log(`Fetching "${compName}" from ${url}...`);
44
+
45
+ try {
46
+ const response = await axios.get(url);
47
+ const localPath = path.join(targetDir, `${compName}.${type}`);
48
+
49
+ // Save component file locally
50
+ await fs.writeFile(localPath, response.data);
51
+ console.log(`"${compName}" saved to ${localPath}`);
52
+
53
+ // Install dependencies if any
54
+ if (comp.dependencies?.length) {
55
+ console.log(
56
+ `Installing dependencies for "${compName}": ${comp.dependencies.join(
57
+ ", "
58
+ )}`
59
+ );
60
+ await execPromise(
61
+ `npm install ${comp.dependencies.join(" ")} --save`
62
+ );
63
+ }
64
+ } catch (err) {
65
+ console.log(`Failed to fetch "${compName}" from repo.`);
66
+ }
67
+ }
68
+
69
+ console.log("\n Components added successfully!");
70
+ } catch (err) {
71
+ console.log("Failed to fetch registry or process components.", err);
72
+ }
73
+ });
74
+
75
+ program.parse(process.argv);
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "theflowui",
3
+ "version": "1.0.0",
4
+ "bin": {
5
+ "flowui": "./index.js"
6
+ },
7
+ "description": "This is the official CLI for the FlowUI library.",
8
+ "keywords": [
9
+ "CLI"
10
+ ],
11
+ "homepage": "https://github.com/KushalXCoder/flowui-cli#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/KushalXCoder/flowui-cli/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/KushalXCoder/flowui-cli.git"
18
+ },
19
+ "license": "ISC",
20
+ "author": "Kushal",
21
+ "type": "module",
22
+ "main": "index.js",
23
+ "scripts": {
24
+ "test": "echo \"Error: no test specified\" && exit 1"
25
+ },
26
+ "dependencies": {
27
+ "axios": "^1.13.5",
28
+ "commander": "^14.0.3",
29
+ "fs-extra": "^11.3.3"
30
+ }
31
+ }