@brxndxndiaz/ui 0.1.3 → 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.
@@ -4,7 +4,7 @@
4
4
  const fs = require("fs");
5
5
  const path = require("path");
6
6
  const { spawnSync } = require("child_process");
7
- const readline = require("readline");
7
+ const inquirer = require("inquirer");
8
8
 
9
9
  const REGISTRY_BASE = "https://ui.brndndiaz.dev/r";
10
10
  const SOURCE_BASE = process.env.BRXN_SOURCE_BASE;
@@ -63,16 +63,13 @@ function readJson(filePath) {
63
63
  }
64
64
 
65
65
  function prompt(question) {
66
- const rl = readline.createInterface({
67
- input: process.stdin,
68
- output: process.stdout,
69
- });
70
- return new Promise((resolve) => {
71
- rl.question(question, (answer) => {
72
- rl.close();
73
- resolve(answer.trim());
74
- });
75
- });
66
+ return inquirer.prompt([
67
+ {
68
+ type: "input",
69
+ name: "answer",
70
+ message: question,
71
+ },
72
+ ]).then((answers) => answers.answer);
76
73
  }
77
74
 
78
75
  function parseSelection(input, max) {
@@ -207,14 +204,17 @@ async function promptForComponentsRoot(projectRoot) {
207
204
  const defaults = ["components", "src/components", "app/components", "src/app/components"];
208
205
  const options = detection && Array.isArray(detection) ? detection : defaults;
209
206
 
210
- console.log("\nSelect a components directory:");
211
- options.forEach((option, index) => {
212
- console.log(` ${index + 1}) ${option}`);
213
- });
214
- const answer = await prompt("Enter a number (default 1): ");
215
- const selection = parseSelection(answer || "1", options.length)[0] || 1;
216
- const chosen = options[selection - 1] || options[0];
217
- return chosen;
207
+ const answers = await inquirer.prompt([
208
+ {
209
+ type: "list",
210
+ name: "root",
211
+ message: "Select a components directory:",
212
+ choices: options,
213
+ default: options[0],
214
+ },
215
+ ]);
216
+
217
+ return answers.root;
218
218
  }
219
219
 
220
220
  function resolveComponentTarget(targetPath, componentsRoot) {
@@ -324,18 +324,26 @@ async function promptForRegistryComponents(componentsRoot) {
324
324
  process.exit(0);
325
325
  }
326
326
 
327
- console.log("\nWhich components would you like to add?");
328
- available.forEach((item, index) => {
329
- console.log(` ${index + 1}) ${item.name}`);
330
- });
331
- console.log("Enter numbers separated by commas (or 'all'):");
332
- const answer = await prompt("> ");
333
- const selections = parseSelection(answer, available.length);
334
- if (!selections.length) {
327
+ const answers = await inquirer.prompt([
328
+ {
329
+ type: "checkbox",
330
+ name: "components",
331
+ message: "Which components would you like to add?",
332
+ choices: available.map((item) => ({
333
+ name: item.name,
334
+ value: item.name,
335
+ checked: false,
336
+ })),
337
+ pageSize: 10,
338
+ },
339
+ ]);
340
+
341
+ if (!answers.components.length) {
335
342
  console.log("No components selected. Exiting.");
336
343
  process.exit(1);
337
344
  }
338
- return selections.map((index) => available[index - 1].name);
345
+
346
+ return answers.components;
339
347
  }
340
348
 
341
349
  function resolveTailwindCssPath(projectRoot) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brxndxndiaz/ui",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "description": "CLI for the brxndxndiaz UI registry.",
6
6
  "scripts": {
@@ -9,7 +9,10 @@
9
9
  "bin": {
10
10
  "brxndxndiaz-ui": "bin/brxndxndiaz-ui.js"
11
11
  },
12
+ "dependencies": {
13
+ "inquirer": "^8.2.5"
14
+ },
12
15
  "engines": {
13
16
  "node": ">=18"
14
17
  }
15
- }
18
+ }