@ijuantm/simpl-addon 2.6.1 → 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 +24 -11
  2. package/package.json +1 -1
package/install.js CHANGED
@@ -158,18 +158,13 @@ const resolveAddon = async (input, addons) => {
158
158
  log(` ${COLORS.yellow}Did you mean:${COLORS.reset} ${COLORS.cyan}${suggestion}${COLORS.reset}?`);
159
159
  console.log();
160
160
 
161
- while (true) {
162
- const answer = await promptUser(` Use "${suggestion}"? ${COLORS.dim}(yes / no / list)${COLORS.reset}`);
163
- 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();
164
163
 
165
- if (a === 'yes' || a === 'y') return suggestion;
166
- if (a === 'list') {
167
- listAddons(addons);
168
- break;
169
- }
170
- if (a === 'no' || a === 'n') break;
164
+ if (a === 'yes' || a === 'y') return suggestion;
171
165
 
172
- 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}`);
173
168
  }
174
169
  }
175
170
 
@@ -177,7 +172,25 @@ const resolveAddon = async (input, addons) => {
177
172
  log(` ${COLORS.bold}Available add-ons:${COLORS.reset}`, 'blue');
178
173
  listAddons(addons);
179
174
  console.log();
180
- 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
+ }
181
194
  };
182
195
 
183
196
  const listAddons = (addons) => addons.forEach((name, i) => log(` ${COLORS.cyan}${i + 1}.${COLORS.reset} ${name}`));
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.1",
4
+ "version": "2.6.2",
5
5
  "scripts": {
6
6
  "link": "npm link",
7
7
  "unlink": "npm unlink -g @ijuantm/simpl-addon"