pui-inject 0.1.6 → 0.1.8

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/bin/pui-inject.js +63 -17
  2. package/package.json +1 -1
package/bin/pui-inject.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  import axios from "axios";
4
4
  import fs from "fs-extra";
@@ -10,7 +10,11 @@ const componentName = process.argv[2];
10
10
 
11
11
  if (!componentName) {
12
12
  console.log(
13
- chalk.red("✖ Usage: pui-inject <component-name>\nExample: pui-inject sidebar01")
13
+ chalk.red.bold("✖ Missing component name\n") +
14
+ chalk.gray("Usage: ") +
15
+ chalk.cyan("pui-inject <component-name>\n") +
16
+ chalk.gray("Example: ") +
17
+ chalk.cyan("pui-inject sidebar01")
14
18
  );
15
19
  process.exit(1);
16
20
  }
@@ -18,28 +22,38 @@ if (!componentName) {
18
22
  const REGISTRY_URL =
19
23
  "https://raw.githubusercontent.com/komal-rastogi080/PUI_flutter_cli/main/manifest.json";
20
24
 
25
+ const sleep = (ms) => new Promise((res) => setTimeout(res, ms));
26
+
21
27
  async function run() {
22
- const spinner = ora("Fetching PUI registry...").start();
28
+ const spinner = ora({
29
+ text: "Fetching PUI registry",
30
+ spinner: "dots",
31
+ }).start();
23
32
 
24
33
  try {
25
- // 1. Fetch manifest
34
+ /* ---------------- FETCH MANIFEST ---------------- */
26
35
  const { data: manifest } = await axios.get(REGISTRY_URL);
27
36
 
28
37
  const component = manifest.components[componentName];
29
38
 
30
39
  if (!component) {
31
- spinner.fail("Component not found in registry");
40
+ spinner.fail("Component not found");
41
+
32
42
  console.log(
33
- chalk.yellow("Available components:"),
34
- Object.keys(manifest.components).join(", ")
43
+ "\n" +
44
+ chalk.yellow.bold("Available components:\n") +
45
+ Object.keys(manifest.components)
46
+ .map((c) => ` • ${chalk.cyan(c)}`)
47
+ .join("\n")
35
48
  );
36
49
  process.exit(1);
37
50
  }
38
51
 
39
52
  spinner.succeed("Component found");
53
+ await sleep(300);
40
54
 
41
- const baseRawUrl = REGISTRY_URL
42
- .replace("/manifest.json", "");
55
+ /* ---------------- PATH SETUP ---------------- */
56
+ const baseRawUrl = REGISTRY_URL.replace("/manifest.json", "");
43
57
 
44
58
  const targetDir = path.join(
45
59
  process.cwd(),
@@ -50,17 +64,21 @@ async function run() {
50
64
 
51
65
  fs.ensureDirSync(targetDir);
52
66
 
53
- // 2. Download files
67
+ const addedFiles = [];
68
+
69
+ /* ---------------- DOWNLOAD FILES ---------------- */
54
70
  for (const file of component.files) {
55
71
  const fileUrl = `${baseRawUrl}/${component.path}/${file}`;
56
72
  const targetPath = path.join(targetDir, file);
57
73
 
58
- const fileSpinner = ora(`Downloading ${file}`).start();
74
+ const fileSpinner = ora(`Injecting ${file}`).start();
59
75
 
60
76
  try {
61
77
  const response = await axios.get(fileUrl);
62
78
  fs.writeFileSync(targetPath, response.data);
63
- fileSpinner.succeed(`${file} added`);
79
+ addedFiles.push(file);
80
+ fileSpinner.succeed(`${file} injected`);
81
+ await sleep(120);
64
82
  } catch (err) {
65
83
  fileSpinner.fail(`Failed to download ${file}`);
66
84
  console.log(chalk.red("URL:"), fileUrl);
@@ -68,13 +86,41 @@ async function run() {
68
86
  }
69
87
  }
70
88
 
71
- console.log(
72
- chalk.green(`\n✔ ${componentName} successfully added to:`),
73
- chalk.cyan(`lib/components/${componentName}`)
74
- );
89
+ /* ---------------- SUCCESS BANNER ---------------- */
90
+ await sleep(400);
91
+
92
+ const border = chalk.hex("#7CFFB2");
93
+ const glow = chalk.hex("#5EEAD4").bold;
94
+ const accent = chalk.hex("#A78BFA");
95
+ const dim = chalk.gray;
96
+
97
+ console.log(`
98
+ ${border("╭──────────────────────────────────────────────────╮")}
99
+ ${border("│")} ${border("│")}
100
+ ${border("│")} ${glow("✨ PUI Inject · Component Ready")} ${border("│")}
101
+ ${border("│")} ${border("│")}
102
+ ${border("╰──────────────────────────────────────────────────╯")}
103
+
104
+ ${accent("▸ Component")}
105
+ ${chalk.bold.white(componentName)}
106
+
107
+ ${accent("▸ Injected Path")}
108
+ ${chalk.white(`lib/components/${componentName}`)}
109
+
110
+ ${accent("▸ Files Added")}
111
+ ${addedFiles.map(f => ` ${chalk.green("✔")} ${chalk.white(f)}`).join("\n")}
112
+
113
+ ${dim("──────────────────────────────────────────────────")}
114
+
115
+ ${chalk.yellow.bold("Next steps")}
116
+ 1. Import the widget into your screen
117
+ 2. Adjust theme & layout as needed
118
+ 3. Build faster with ${chalk.bold("PUI")} 🚀
119
+ `);
120
+
75
121
  } catch (error) {
76
122
  spinner.fail("Failed to fetch registry");
77
- console.error(error.message);
123
+ console.error(chalk.red(error.message));
78
124
  process.exit(1);
79
125
  }
80
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pui-inject",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "bin": {
5
5
  "pui-inject": "bin/pui-inject.js"
6
6
  },