@ijuantm/simpl-addon 2.6.0 → 2.6.2

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 +27 -11
  2. package/package.json +1 -1
package/install.js CHANGED
@@ -69,6 +69,8 @@ const promptUser = (question, defaultValue = '') => new Promise(resolve => {
69
69
  });
70
70
  });
71
71
 
72
+ const printAnswer = (question, value) => console.log(`${question}: ${COLORS.cyan}${value}${COLORS.reset}`);
73
+
72
74
  const getSimplVersion = () => {
73
75
  const simplFile = path.join(process.cwd(), '.simpl');
74
76
 
@@ -156,18 +158,13 @@ const resolveAddon = async (input, addons) => {
156
158
  log(` ${COLORS.yellow}Did you mean:${COLORS.reset} ${COLORS.cyan}${suggestion}${COLORS.reset}?`);
157
159
  console.log();
158
160
 
159
- while (true) {
160
- const answer = await promptUser(` Use "${suggestion}"? ${COLORS.dim}(yes / no / list)${COLORS.reset}`);
161
- const a = answer.toLowerCase();
161
+ const answer = await promptUser(` Use "${suggestion}"? ${COLORS.dim}(y/n — n shows available add-ons)${COLORS.reset}`);
162
+ const a = answer.toLowerCase();
162
163
 
163
- if (a === 'yes' || a === 'y') return suggestion;
164
- if (a === 'list') {
165
- listAddons(addons);
166
- break;
167
- }
168
- if (a === 'no' || a === 'n') break;
164
+ if (a === 'yes' || a === 'y') return suggestion;
169
165
 
170
- log(` ${COLORS.dim}Please answer yes, no, or list${COLORS.reset}`);
166
+ if (a !== 'no' && a !== 'n') {
167
+ log(` ${COLORS.dim}Please answer y or n${COLORS.reset}`);
171
168
  }
172
169
  }
173
170
 
@@ -175,7 +172,25 @@ const resolveAddon = async (input, addons) => {
175
172
  log(` ${COLORS.bold}Available add-ons:${COLORS.reset}`, 'blue');
176
173
  listAddons(addons);
177
174
  console.log();
178
- process.exit(1);
175
+
176
+ while (true) {
177
+ const input2 = await promptUser(` Add-on to install ${COLORS.dim}(name or number)${COLORS.reset}`);
178
+
179
+ if (!input2) {
180
+ log(` ${COLORS.red}✗${COLORS.reset} Selection cannot be empty`, 'red');
181
+ console.log();
182
+ continue;
183
+ }
184
+
185
+ const numInput = parseInt(input2, 10);
186
+ if (!isNaN(numInput) && numInput >= 1 && numInput <= addons.length) return addons[numInput - 1];
187
+ if (addons.includes(input2)) return input2;
188
+
189
+ const suggestion2 = closestMatch(input2, addons);
190
+ log(` ${COLORS.red}✗${COLORS.reset} Invalid selection ${COLORS.bold}${input2}${COLORS.reset}`, 'red');
191
+ if (suggestion2) log(` ${COLORS.dim}Did you mean ${COLORS.reset}${COLORS.cyan}${suggestion2}${COLORS.reset}${COLORS.dim}?${COLORS.reset}`);
192
+ console.log();
193
+ }
179
194
  };
180
195
 
181
196
  const listAddons = (addons) => addons.forEach((name, i) => log(` ${COLORS.cyan}${i + 1}.${COLORS.reset} ${name}`));
@@ -594,6 +609,7 @@ const main = async () => {
594
609
 
595
610
  if (parsed.addon) {
596
611
  addonName = await resolveAddon(parsed.addon, addons);
612
+ printAnswer(' Add-on to install', addonName);
597
613
  } else {
598
614
  console.log();
599
615
  log(` ${COLORS.bold}Available add-ons:${COLORS.reset}`, 'blue');
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.6.0",
4
+ "version": "2.6.2",
5
5
  "scripts": {
6
6
  "link": "npm link",
7
7
  "unlink": "npm unlink -g @ijuantm/simpl-addon"