pui-inject 0.1.7 → 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 +52 -29
  2. package/package.json +1 -1
package/bin/pui-inject.js CHANGED
@@ -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,36 +86,41 @@ async function run() {
68
86
  }
69
87
  }
70
88
 
71
- spinner.succeed("Component injected successfully");
72
- await new Promise(res => setTimeout(res, 300));
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;
73
96
 
74
97
  console.log(`
75
- ${chalk.hex("#7CFFB2").bold("╭──────────────────────────────────────────────╮")}
76
- ${chalk.hex("#7CFFB2").bold("│")} ${chalk.hex("#7CFFB2").bold("│")}
77
- ${chalk.hex("#7CFFB2").bold("│")} ${chalk.bold("✨ PUI Inject Component Ready")} ${chalk.hex("#7CFFB2").bold("│")}
78
- ${chalk.hex("#7CFFB2").bold("│")} ${chalk.hex("#7CFFB2").bold("│")}
79
- ${chalk.hex("#7CFFB2").bold("╰──────────────────────────────────────────────╯")}
98
+ ${border("╭──────────────────────────────────────────────────╮")}
99
+ ${border("│")} ${border("│")}
100
+ ${border("│")} ${glow("✨ PUI Inject · Component Ready")} ${border("│")}
101
+ ${border("│")} ${border("│")}
102
+ ${border("╰──────────────────────────────────────────────────╯")}
80
103
 
81
- ${chalk.cyan("Component")}
82
- ${chalk.bold(componentName)}
104
+ ${accent("Component")}
105
+ ${chalk.bold.white(componentName)}
83
106
 
84
- ${chalk.cyan("Injected Into")}
85
- lib/components/${componentName}
107
+ ${accent("Injected Path")}
108
+ ${chalk.white(`lib/components/${componentName}`)}
86
109
 
87
- ${chalk.cyan("Files Added")}
88
- ${files.map(f => ` ${chalk.green("✔")} ${f}`).join("\n")}
110
+ ${accent("Files Added")}
111
+ ${addedFiles.map(f => ` ${chalk.green("✔")} ${chalk.white(f)}`).join("\n")}
89
112
 
90
- ${chalk.gray("──────────────────────────────────────────────")}
113
+ ${dim("──────────────────────────────────────────────────")}
91
114
 
92
- ${chalk.yellow("Next Steps")}
115
+ ${chalk.yellow.bold("Next steps")}
93
116
  1. Import the widget into your screen
94
- 2. Customize layout & theme
95
- 3. Ship faster 🚀
117
+ 2. Adjust theme & layout as needed
118
+ 3. Build faster with ${chalk.bold("PUI")} 🚀
96
119
  `);
97
120
 
98
121
  } catch (error) {
99
122
  spinner.fail("Failed to fetch registry");
100
- console.error(error.message);
123
+ console.error(chalk.red(error.message));
101
124
  process.exit(1);
102
125
  }
103
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pui-inject",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "bin": {
5
5
  "pui-inject": "bin/pui-inject.js"
6
6
  },