@ijuantm/simpl-addon 2.4.4 → 2.4.6

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/install.js +47 -32
  2. package/package.json +1 -1
package/install.js CHANGED
@@ -89,14 +89,12 @@ const showHelp = () => {
89
89
  console.log();
90
90
  log(` ${COLORS.bold}Usage:${COLORS.reset}`, 'blue');
91
91
  log(` ${COLORS.dim}npx @ijuantm/simpl-addon${COLORS.reset}`);
92
+ log(` ${COLORS.dim}npx @ijuantm/simpl-addon <add-on>${COLORS.reset}`);
92
93
  log(` ${COLORS.dim}npx @ijuantm/simpl-addon --help${COLORS.reset}`);
93
94
  console.log();
94
95
  log(` ${COLORS.bold}Commands:${COLORS.reset}`, 'blue');
95
96
  log(` ${COLORS.dim}--help, -h${COLORS.reset} Show this help message`);
96
97
  console.log();
97
- log(` ${COLORS.bold}Examples:${COLORS.reset}`, 'blue');
98
- log(` ${COLORS.dim}npx @ijuantm/simpl-addon${COLORS.reset}`);
99
- console.log();
100
98
  log(` ${COLORS.bold}Note:${COLORS.reset}`, 'blue');
101
99
  log(` Run this command from the root of your Simpl project.`);
102
100
  log(` The add-on version will match your Simpl framework version.`);
@@ -393,6 +391,8 @@ const main = async () => {
393
391
  process.exit(0);
394
392
  }
395
393
 
394
+ const directName = firstArg && !firstArg.startsWith('-') ? firstArg : null;
395
+
396
396
  let version;
397
397
 
398
398
  try {
@@ -404,11 +404,13 @@ const main = async () => {
404
404
  process.exit(1);
405
405
  }
406
406
 
407
- console.log();
408
- log(` ╭${'─'.repeat(62)}╮`);
409
- log(` │ ${COLORS.bold}Simpl Add-on Installer${COLORS.reset} ${COLORS.dim}(v${version})${COLORS.reset}${' '.repeat(34 - version.length)}│`);
410
- log(` ╰${''.repeat(62)}╯`);
411
- console.log();
407
+ if (!directName) {
408
+ console.log();
409
+ log(` ╭${''.repeat(62)}╮`);
410
+ log(` │ ${COLORS.bold}Simpl Add-on Installer${COLORS.reset} ${COLORS.dim}(v${version})${COLORS.reset}${' '.repeat(34 - version.length)}│`);
411
+ log(` ╰${'─'.repeat(62)}╯`);
412
+ console.log();
413
+ }
412
414
 
413
415
  let versionsData;
414
416
 
@@ -452,7 +454,7 @@ const main = async () => {
452
454
  process.exit(1);
453
455
  }
454
456
 
455
- log(' 📦 Fetching available add-ons...', 'bold');
457
+ if (!directName) log(' 🧰 Fetching available add-ons...', 'bold');
456
458
 
457
459
  let addons;
458
460
 
@@ -466,42 +468,55 @@ const main = async () => {
466
468
  process.exit(1);
467
469
  }
468
470
 
469
- console.log();
470
-
471
471
  if (addons.length === 0) {
472
+ console.log();
472
473
  log(` ${COLORS.yellow}⚠${COLORS.reset} No add-ons available for this version`);
473
474
  console.log();
474
475
  process.exit(0);
475
476
  }
476
477
 
477
- log(` ${COLORS.bold}Available add-ons:${COLORS.reset}`, 'blue');
478
- addons.forEach((name, index) => log(` ${COLORS.cyan}${index + 1}.${COLORS.reset} ${name}`));
479
- console.log();
480
-
481
478
  let addonName;
482
479
 
483
- while (true) {
484
- const input = await promptUser(` Add-on to install ${COLORS.dim}(name or number)${COLORS.reset}`);
485
-
486
- if (!input) {
487
- log(` ${COLORS.red}✗${COLORS.reset} Selection cannot be empty`, 'red');
480
+ if (directName) {
481
+ if (!addons.includes(directName)) {
482
+ console.log();
483
+ log(` ${COLORS.red}✗${COLORS.reset} Add-on ${COLORS.bold}${directName}${COLORS.reset} not found`, 'red');
488
484
  console.log();
489
- continue;
485
+ log(` ${COLORS.bold}Available add-ons:${COLORS.reset}`, 'blue');
486
+ addons.forEach((name, index) => log(` ${COLORS.cyan}${index + 1}.${COLORS.reset} ${name}`));
487
+ console.log();
488
+ process.exit(1);
490
489
  }
490
+ addonName = directName;
491
+ } else {
492
+ console.log();
493
+ log(` ${COLORS.bold}Available add-ons:${COLORS.reset}`, 'blue');
494
+ addons.forEach((name, index) => log(` ${COLORS.cyan}${index + 1}.${COLORS.reset} ${name}`));
495
+ console.log();
491
496
 
492
- const numInput = parseInt(input, 10);
493
- if (!isNaN(numInput) && numInput >= 1 && numInput <= addons.length) {
494
- addonName = addons[numInput - 1];
495
- break;
496
- }
497
+ while (true) {
498
+ const input = await promptUser(` Add-on to install ${COLORS.dim}(name or number)${COLORS.reset}`);
497
499
 
498
- if (addons.includes(input)) {
499
- addonName = input;
500
- break;
501
- }
500
+ if (!input) {
501
+ log(` ${COLORS.red}✗${COLORS.reset} Selection cannot be empty`, 'red');
502
+ console.log();
503
+ continue;
504
+ }
502
505
 
503
- log(` ${COLORS.red}✗${COLORS.reset} Invalid selection "${input}"`, 'red');
504
- console.log();
506
+ const numInput = parseInt(input, 10);
507
+ if (!isNaN(numInput) && numInput >= 1 && numInput <= addons.length) {
508
+ addonName = addons[numInput - 1];
509
+ break;
510
+ }
511
+
512
+ if (addons.includes(input)) {
513
+ addonName = input;
514
+ break;
515
+ }
516
+
517
+ log(` ${COLORS.red}✗${COLORS.reset} Invalid selection "${input}"`, 'red');
518
+ console.log();
519
+ }
505
520
  }
506
521
 
507
522
  console.log();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ijuantm/simpl-addon",
3
3
  "description": "CLI tool to install Simpl framework add-ons.",
4
- "version": "2.4.4",
4
+ "version": "2.4.6",
5
5
  "scripts": {
6
6
  "link": "npm link",
7
7
  "unlink": "npm unlink -g @ijuantm/simpl-addon"