@ijuantm/simpl-addon 2.6.2 → 2.6.3
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.
- package/install.js +33 -53
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -147,49 +147,53 @@ const closestMatch = (input, options) => {
|
|
|
147
147
|
|
|
148
148
|
// --- Fuzzy addon resolution with interactive prompts ---
|
|
149
149
|
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const suggestion = closestMatch(input, addons);
|
|
154
|
-
console.log();
|
|
155
|
-
log(` ${COLORS.red}✗${COLORS.reset} Add-on ${COLORS.bold}${input}${COLORS.reset} not found`, 'red');
|
|
156
|
-
|
|
157
|
-
if (suggestion) {
|
|
158
|
-
log(` ${COLORS.yellow}Did you mean:${COLORS.reset} ${COLORS.cyan}${suggestion}${COLORS.reset}?`);
|
|
150
|
+
const promptAddon = async (addons, firstInput = null) => {
|
|
151
|
+
const askSuggestion = async (input) => {
|
|
152
|
+
const suggestion = closestMatch(input, addons);
|
|
159
153
|
console.log();
|
|
154
|
+
log(` ${COLORS.red}✗${COLORS.reset} Add-on ${COLORS.bold}${input}${COLORS.reset} not found`, 'red');
|
|
160
155
|
|
|
161
|
-
|
|
162
|
-
|
|
156
|
+
if (suggestion) {
|
|
157
|
+
log(` ${COLORS.yellow}Did you mean:${COLORS.reset} ${COLORS.cyan}${suggestion}${COLORS.reset}?`);
|
|
158
|
+
console.log();
|
|
163
159
|
|
|
164
|
-
|
|
160
|
+
while (true) {
|
|
161
|
+
const answer = await promptUser(` Use "${suggestion}"? ${COLORS.dim}(yes / no — no lists available add-ons)${COLORS.reset}`);
|
|
162
|
+
const a = answer.toLowerCase();
|
|
165
163
|
|
|
166
|
-
|
|
167
|
-
|
|
164
|
+
if (a === 'yes' || a === 'y') return suggestion;
|
|
165
|
+
if (a === 'no' || a === 'n') break;
|
|
166
|
+
|
|
167
|
+
log(` ${COLORS.dim}Please answer yes or no${COLORS.reset}`);
|
|
168
|
+
}
|
|
168
169
|
}
|
|
169
|
-
}
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
console.log();
|
|
172
|
+
log(` ${COLORS.bold}Available add-ons:${COLORS.reset}`, 'blue');
|
|
173
|
+
listAddons(addons);
|
|
174
|
+
console.log();
|
|
175
|
+
|
|
176
|
+
return null;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
let pending = firstInput;
|
|
175
180
|
|
|
176
181
|
while (true) {
|
|
177
|
-
const
|
|
182
|
+
const input = pending || await promptUser(` Add-on to install ${COLORS.dim}(name or number)${COLORS.reset}`);
|
|
183
|
+
pending = null;
|
|
178
184
|
|
|
179
|
-
if (!
|
|
185
|
+
if (!input) {
|
|
180
186
|
log(` ${COLORS.red}✗${COLORS.reset} Selection cannot be empty`, 'red');
|
|
181
187
|
console.log();
|
|
182
188
|
continue;
|
|
183
189
|
}
|
|
184
190
|
|
|
185
|
-
const numInput = parseInt(
|
|
191
|
+
const numInput = parseInt(input, 10);
|
|
186
192
|
if (!isNaN(numInput) && numInput >= 1 && numInput <= addons.length) return addons[numInput - 1];
|
|
187
|
-
if (addons.includes(
|
|
193
|
+
if (addons.includes(input)) return input;
|
|
188
194
|
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
if (suggestion2) log(` ${COLORS.dim}Did you mean ${COLORS.reset}${COLORS.cyan}${suggestion2}${COLORS.reset}${COLORS.dim}?${COLORS.reset}`);
|
|
192
|
-
console.log();
|
|
195
|
+
const resolved = await askSuggestion(input);
|
|
196
|
+
if (resolved) return resolved;
|
|
193
197
|
}
|
|
194
198
|
};
|
|
195
199
|
|
|
@@ -608,7 +612,7 @@ const main = async () => {
|
|
|
608
612
|
let addonName;
|
|
609
613
|
|
|
610
614
|
if (parsed.addon) {
|
|
611
|
-
addonName = await
|
|
615
|
+
addonName = await promptAddon(addons, parsed.addon);
|
|
612
616
|
printAnswer(' Add-on to install', addonName);
|
|
613
617
|
} else {
|
|
614
618
|
console.log();
|
|
@@ -616,31 +620,7 @@ const main = async () => {
|
|
|
616
620
|
listAddons(addons);
|
|
617
621
|
console.log();
|
|
618
622
|
|
|
619
|
-
|
|
620
|
-
const input = await promptUser(` Add-on to install ${COLORS.dim}(name or number)${COLORS.reset}`);
|
|
621
|
-
|
|
622
|
-
if (!input) {
|
|
623
|
-
log(` ${COLORS.red}✗${COLORS.reset} Selection cannot be empty`, 'red');
|
|
624
|
-
console.log();
|
|
625
|
-
continue;
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
const numInput = parseInt(input, 10);
|
|
629
|
-
if (!isNaN(numInput) && numInput >= 1 && numInput <= addons.length) {
|
|
630
|
-
addonName = addons[numInput - 1];
|
|
631
|
-
break;
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
if (addons.includes(input)) {
|
|
635
|
-
addonName = input;
|
|
636
|
-
break;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
const suggestion = closestMatch(input, addons);
|
|
640
|
-
log(` ${COLORS.red}✗${COLORS.reset} Invalid selection ${COLORS.bold}${input}${COLORS.reset}`, 'red');
|
|
641
|
-
if (suggestion) log(` ${COLORS.dim}Did you mean ${COLORS.reset}${COLORS.cyan}${suggestion}${COLORS.reset}${COLORS.dim}?${COLORS.reset}`);
|
|
642
|
-
console.log();
|
|
643
|
-
}
|
|
623
|
+
addonName = await promptAddon(addons);
|
|
644
624
|
}
|
|
645
625
|
|
|
646
626
|
console.log();
|