@optique/inquirer 1.0.0-dev.560 → 1.0.0-dev.561
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/dist/index.cjs +94 -83
- package/dist/index.js +94 -83
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -42,6 +42,9 @@ function getPromptFunctions() {
|
|
|
42
42
|
const override = globalThis[promptFunctionsOverrideSymbol];
|
|
43
43
|
return override ?? defaultPromptFunctions;
|
|
44
44
|
}
|
|
45
|
+
function isExitPromptError(error) {
|
|
46
|
+
return typeof error === "object" && error != null && "name" in error && error.name === "ExitPromptError";
|
|
47
|
+
}
|
|
45
48
|
/**
|
|
46
49
|
* Wraps a parser with an interactive Inquirer.js prompt fallback.
|
|
47
50
|
*
|
|
@@ -83,97 +86,105 @@ function prompt(parser, config) {
|
|
|
83
86
|
let promptCache = null;
|
|
84
87
|
async function executePrompt() {
|
|
85
88
|
const prompts = getPromptFunctions();
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
error: __optique_core_message.message`No number provided.`
|
|
91
|
-
};
|
|
92
|
-
return {
|
|
93
|
-
success: true,
|
|
94
|
-
value
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
switch (cfg.type) {
|
|
98
|
-
case "confirm": return {
|
|
99
|
-
success: true,
|
|
100
|
-
value: await prompts.confirm({
|
|
101
|
-
message: cfg.message,
|
|
102
|
-
...cfg.default !== void 0 ? { default: cfg.default } : {}
|
|
103
|
-
})
|
|
104
|
-
};
|
|
105
|
-
case "number": {
|
|
106
|
-
const numResult = await prompts.number({
|
|
107
|
-
message: cfg.message,
|
|
108
|
-
...cfg.default !== void 0 ? { default: cfg.default } : {},
|
|
109
|
-
...cfg.min !== void 0 ? { min: cfg.min } : {},
|
|
110
|
-
...cfg.max !== void 0 ? { max: cfg.max } : {},
|
|
111
|
-
...cfg.step !== void 0 ? { step: cfg.step } : {}
|
|
112
|
-
});
|
|
113
|
-
if (numResult === void 0) return {
|
|
89
|
+
try {
|
|
90
|
+
if ("prompter" in cfg && cfg.prompter != null) {
|
|
91
|
+
const value = await cfg.prompter();
|
|
92
|
+
if (cfg.type === "number" && value === void 0) return {
|
|
114
93
|
success: false,
|
|
115
94
|
error: __optique_core_message.message`No number provided.`
|
|
116
95
|
};
|
|
117
96
|
return {
|
|
118
97
|
success: true,
|
|
119
|
-
value
|
|
98
|
+
value
|
|
120
99
|
};
|
|
121
100
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
101
|
+
switch (cfg.type) {
|
|
102
|
+
case "confirm": return {
|
|
103
|
+
success: true,
|
|
104
|
+
value: await prompts.confirm({
|
|
105
|
+
message: cfg.message,
|
|
106
|
+
...cfg.default !== void 0 ? { default: cfg.default } : {}
|
|
107
|
+
})
|
|
108
|
+
};
|
|
109
|
+
case "number": {
|
|
110
|
+
const numResult = await prompts.number({
|
|
111
|
+
message: cfg.message,
|
|
112
|
+
...cfg.default !== void 0 ? { default: cfg.default } : {},
|
|
113
|
+
...cfg.min !== void 0 ? { min: cfg.min } : {},
|
|
114
|
+
...cfg.max !== void 0 ? { max: cfg.max } : {},
|
|
115
|
+
...cfg.step !== void 0 ? { step: cfg.step } : {}
|
|
116
|
+
});
|
|
117
|
+
if (numResult === void 0) return {
|
|
118
|
+
success: false,
|
|
119
|
+
error: __optique_core_message.message`No number provided.`
|
|
120
|
+
};
|
|
121
|
+
return {
|
|
122
|
+
success: true,
|
|
123
|
+
value: numResult
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
case "input": return {
|
|
127
|
+
success: true,
|
|
128
|
+
value: await prompts.input({
|
|
129
|
+
message: cfg.message,
|
|
130
|
+
...cfg.default !== void 0 ? { default: cfg.default } : {},
|
|
131
|
+
...cfg.validate !== void 0 ? { validate: cfg.validate } : {}
|
|
132
|
+
})
|
|
133
|
+
};
|
|
134
|
+
case "password": return {
|
|
135
|
+
success: true,
|
|
136
|
+
value: await prompts.password({
|
|
137
|
+
message: cfg.message,
|
|
138
|
+
...cfg.mask !== void 0 ? { mask: cfg.mask } : {},
|
|
139
|
+
...cfg.validate !== void 0 ? { validate: cfg.validate } : {}
|
|
140
|
+
})
|
|
141
|
+
};
|
|
142
|
+
case "editor": return {
|
|
143
|
+
success: true,
|
|
144
|
+
value: await prompts.editor({
|
|
145
|
+
message: cfg.message,
|
|
146
|
+
...cfg.default !== void 0 ? { default: cfg.default } : {},
|
|
147
|
+
...cfg.validate !== void 0 ? { validate: cfg.validate } : {}
|
|
148
|
+
})
|
|
149
|
+
};
|
|
150
|
+
case "select": return {
|
|
151
|
+
success: true,
|
|
152
|
+
value: await prompts.select({
|
|
153
|
+
message: cfg.message,
|
|
154
|
+
choices: normalizeChoices(cfg.choices),
|
|
155
|
+
...cfg.default !== void 0 ? { default: cfg.default } : {}
|
|
156
|
+
})
|
|
157
|
+
};
|
|
158
|
+
case "rawlist": return {
|
|
159
|
+
success: true,
|
|
160
|
+
value: await prompts.rawlist({
|
|
161
|
+
message: cfg.message,
|
|
162
|
+
choices: normalizeChoices(cfg.choices),
|
|
163
|
+
...cfg.default !== void 0 ? { default: cfg.default } : {}
|
|
164
|
+
})
|
|
165
|
+
};
|
|
166
|
+
case "expand": return {
|
|
167
|
+
success: true,
|
|
168
|
+
value: await prompts.expand({
|
|
169
|
+
message: cfg.message,
|
|
170
|
+
choices: cfg.choices,
|
|
171
|
+
...cfg.default !== void 0 ? { default: cfg.default } : {}
|
|
172
|
+
})
|
|
173
|
+
};
|
|
174
|
+
case "checkbox": return {
|
|
175
|
+
success: true,
|
|
176
|
+
value: await prompts.checkbox({
|
|
177
|
+
message: cfg.message,
|
|
178
|
+
choices: normalizeChoices(cfg.choices)
|
|
179
|
+
})
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
} catch (error) {
|
|
183
|
+
if (isExitPromptError(error)) return {
|
|
184
|
+
success: false,
|
|
185
|
+
error: __optique_core_message.message`Prompt cancelled.`
|
|
176
186
|
};
|
|
187
|
+
throw error;
|
|
177
188
|
}
|
|
178
189
|
}
|
|
179
190
|
return {
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,9 @@ function getPromptFunctions() {
|
|
|
19
19
|
const override = globalThis[promptFunctionsOverrideSymbol];
|
|
20
20
|
return override ?? defaultPromptFunctions;
|
|
21
21
|
}
|
|
22
|
+
function isExitPromptError(error) {
|
|
23
|
+
return typeof error === "object" && error != null && "name" in error && error.name === "ExitPromptError";
|
|
24
|
+
}
|
|
22
25
|
/**
|
|
23
26
|
* Wraps a parser with an interactive Inquirer.js prompt fallback.
|
|
24
27
|
*
|
|
@@ -60,97 +63,105 @@ function prompt(parser, config) {
|
|
|
60
63
|
let promptCache = null;
|
|
61
64
|
async function executePrompt() {
|
|
62
65
|
const prompts = getPromptFunctions();
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
error: message`No number provided.`
|
|
68
|
-
};
|
|
69
|
-
return {
|
|
70
|
-
success: true,
|
|
71
|
-
value
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
switch (cfg.type) {
|
|
75
|
-
case "confirm": return {
|
|
76
|
-
success: true,
|
|
77
|
-
value: await prompts.confirm({
|
|
78
|
-
message: cfg.message,
|
|
79
|
-
...cfg.default !== void 0 ? { default: cfg.default } : {}
|
|
80
|
-
})
|
|
81
|
-
};
|
|
82
|
-
case "number": {
|
|
83
|
-
const numResult = await prompts.number({
|
|
84
|
-
message: cfg.message,
|
|
85
|
-
...cfg.default !== void 0 ? { default: cfg.default } : {},
|
|
86
|
-
...cfg.min !== void 0 ? { min: cfg.min } : {},
|
|
87
|
-
...cfg.max !== void 0 ? { max: cfg.max } : {},
|
|
88
|
-
...cfg.step !== void 0 ? { step: cfg.step } : {}
|
|
89
|
-
});
|
|
90
|
-
if (numResult === void 0) return {
|
|
66
|
+
try {
|
|
67
|
+
if ("prompter" in cfg && cfg.prompter != null) {
|
|
68
|
+
const value = await cfg.prompter();
|
|
69
|
+
if (cfg.type === "number" && value === void 0) return {
|
|
91
70
|
success: false,
|
|
92
71
|
error: message`No number provided.`
|
|
93
72
|
};
|
|
94
73
|
return {
|
|
95
74
|
success: true,
|
|
96
|
-
value
|
|
75
|
+
value
|
|
97
76
|
};
|
|
98
77
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
78
|
+
switch (cfg.type) {
|
|
79
|
+
case "confirm": return {
|
|
80
|
+
success: true,
|
|
81
|
+
value: await prompts.confirm({
|
|
82
|
+
message: cfg.message,
|
|
83
|
+
...cfg.default !== void 0 ? { default: cfg.default } : {}
|
|
84
|
+
})
|
|
85
|
+
};
|
|
86
|
+
case "number": {
|
|
87
|
+
const numResult = await prompts.number({
|
|
88
|
+
message: cfg.message,
|
|
89
|
+
...cfg.default !== void 0 ? { default: cfg.default } : {},
|
|
90
|
+
...cfg.min !== void 0 ? { min: cfg.min } : {},
|
|
91
|
+
...cfg.max !== void 0 ? { max: cfg.max } : {},
|
|
92
|
+
...cfg.step !== void 0 ? { step: cfg.step } : {}
|
|
93
|
+
});
|
|
94
|
+
if (numResult === void 0) return {
|
|
95
|
+
success: false,
|
|
96
|
+
error: message`No number provided.`
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
success: true,
|
|
100
|
+
value: numResult
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
case "input": return {
|
|
104
|
+
success: true,
|
|
105
|
+
value: await prompts.input({
|
|
106
|
+
message: cfg.message,
|
|
107
|
+
...cfg.default !== void 0 ? { default: cfg.default } : {},
|
|
108
|
+
...cfg.validate !== void 0 ? { validate: cfg.validate } : {}
|
|
109
|
+
})
|
|
110
|
+
};
|
|
111
|
+
case "password": return {
|
|
112
|
+
success: true,
|
|
113
|
+
value: await prompts.password({
|
|
114
|
+
message: cfg.message,
|
|
115
|
+
...cfg.mask !== void 0 ? { mask: cfg.mask } : {},
|
|
116
|
+
...cfg.validate !== void 0 ? { validate: cfg.validate } : {}
|
|
117
|
+
})
|
|
118
|
+
};
|
|
119
|
+
case "editor": return {
|
|
120
|
+
success: true,
|
|
121
|
+
value: await prompts.editor({
|
|
122
|
+
message: cfg.message,
|
|
123
|
+
...cfg.default !== void 0 ? { default: cfg.default } : {},
|
|
124
|
+
...cfg.validate !== void 0 ? { validate: cfg.validate } : {}
|
|
125
|
+
})
|
|
126
|
+
};
|
|
127
|
+
case "select": return {
|
|
128
|
+
success: true,
|
|
129
|
+
value: await prompts.select({
|
|
130
|
+
message: cfg.message,
|
|
131
|
+
choices: normalizeChoices(cfg.choices),
|
|
132
|
+
...cfg.default !== void 0 ? { default: cfg.default } : {}
|
|
133
|
+
})
|
|
134
|
+
};
|
|
135
|
+
case "rawlist": return {
|
|
136
|
+
success: true,
|
|
137
|
+
value: await prompts.rawlist({
|
|
138
|
+
message: cfg.message,
|
|
139
|
+
choices: normalizeChoices(cfg.choices),
|
|
140
|
+
...cfg.default !== void 0 ? { default: cfg.default } : {}
|
|
141
|
+
})
|
|
142
|
+
};
|
|
143
|
+
case "expand": return {
|
|
144
|
+
success: true,
|
|
145
|
+
value: await prompts.expand({
|
|
146
|
+
message: cfg.message,
|
|
147
|
+
choices: cfg.choices,
|
|
148
|
+
...cfg.default !== void 0 ? { default: cfg.default } : {}
|
|
149
|
+
})
|
|
150
|
+
};
|
|
151
|
+
case "checkbox": return {
|
|
152
|
+
success: true,
|
|
153
|
+
value: await prompts.checkbox({
|
|
154
|
+
message: cfg.message,
|
|
155
|
+
choices: normalizeChoices(cfg.choices)
|
|
156
|
+
})
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
} catch (error) {
|
|
160
|
+
if (isExitPromptError(error)) return {
|
|
161
|
+
success: false,
|
|
162
|
+
error: message`Prompt cancelled.`
|
|
153
163
|
};
|
|
164
|
+
throw error;
|
|
154
165
|
}
|
|
155
166
|
}
|
|
156
167
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/inquirer",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.561+e8cfa7d8",
|
|
4
4
|
"description": "Interactive prompt support for Optique via Inquirer.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
"sideEffects": false,
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@inquirer/prompts": "^8.3.0",
|
|
59
|
-
"@optique/core": "1.0.0-dev.
|
|
59
|
+
"@optique/core": "1.0.0-dev.561+e8cfa7d8"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/node": "^20.19.9",
|
|
63
63
|
"tsdown": "^0.13.0",
|
|
64
64
|
"typescript": "^5.8.3",
|
|
65
|
-
"@optique/env": "1.0.0-dev.
|
|
65
|
+
"@optique/env": "1.0.0-dev.561+e8cfa7d8"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"build": "tsdown",
|