@optique/inquirer 1.0.0-dev.479 → 1.0.0-dev.487

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 CHANGED
@@ -26,6 +26,22 @@ const __optique_core_annotations = __toESM(require("@optique/core/annotations"))
26
26
  const __optique_core_message = __toESM(require("@optique/core/message"));
27
27
 
28
28
  //#region src/index.ts
29
+ const promptFunctionsOverrideSymbol = Symbol.for("@optique/inquirer/prompt-functions");
30
+ const defaultPromptFunctions = {
31
+ confirm: __inquirer_prompts.confirm,
32
+ number: __inquirer_prompts.number,
33
+ input: __inquirer_prompts.input,
34
+ password: __inquirer_prompts.password,
35
+ editor: __inquirer_prompts.editor,
36
+ select: __inquirer_prompts.select,
37
+ rawlist: __inquirer_prompts.rawlist,
38
+ expand: __inquirer_prompts.expand,
39
+ checkbox: __inquirer_prompts.checkbox
40
+ };
41
+ function getPromptFunctions() {
42
+ const override = globalThis[promptFunctionsOverrideSymbol];
43
+ return override ?? defaultPromptFunctions;
44
+ }
29
45
  /**
30
46
  * Wraps a parser with an interactive Inquirer.js prompt fallback.
31
47
  *
@@ -67,6 +83,7 @@ function prompt(parser, config) {
67
83
  const promptBindInitialState = new PromptBindInitialStateClass();
68
84
  let promptCache = null;
69
85
  async function executePrompt() {
86
+ const prompts = getPromptFunctions();
70
87
  if ("prompter" in cfg && cfg.prompter != null) {
71
88
  const value = await cfg.prompter();
72
89
  if (cfg.type === "number" && value === void 0) return {
@@ -81,13 +98,13 @@ function prompt(parser, config) {
81
98
  switch (cfg.type) {
82
99
  case "confirm": return {
83
100
  success: true,
84
- value: await (0, __inquirer_prompts.confirm)({
101
+ value: await prompts.confirm({
85
102
  message: cfg.message,
86
103
  ...cfg.default !== void 0 ? { default: cfg.default } : {}
87
104
  })
88
105
  };
89
106
  case "number": {
90
- const numResult = await (0, __inquirer_prompts.number)({
107
+ const numResult = await prompts.number({
91
108
  message: cfg.message,
92
109
  ...cfg.default !== void 0 ? { default: cfg.default } : {},
93
110
  ...cfg.min !== void 0 ? { min: cfg.min } : {},
@@ -105,7 +122,7 @@ function prompt(parser, config) {
105
122
  }
106
123
  case "input": return {
107
124
  success: true,
108
- value: await (0, __inquirer_prompts.input)({
125
+ value: await prompts.input({
109
126
  message: cfg.message,
110
127
  ...cfg.default !== void 0 ? { default: cfg.default } : {},
111
128
  ...cfg.validate !== void 0 ? { validate: cfg.validate } : {}
@@ -113,7 +130,7 @@ function prompt(parser, config) {
113
130
  };
114
131
  case "password": return {
115
132
  success: true,
116
- value: await (0, __inquirer_prompts.password)({
133
+ value: await prompts.password({
117
134
  message: cfg.message,
118
135
  ...cfg.mask !== void 0 ? { mask: cfg.mask } : {},
119
136
  ...cfg.validate !== void 0 ? { validate: cfg.validate } : {}
@@ -121,7 +138,7 @@ function prompt(parser, config) {
121
138
  };
122
139
  case "editor": return {
123
140
  success: true,
124
- value: await (0, __inquirer_prompts.editor)({
141
+ value: await prompts.editor({
125
142
  message: cfg.message,
126
143
  ...cfg.default !== void 0 ? { default: cfg.default } : {},
127
144
  ...cfg.validate !== void 0 ? { validate: cfg.validate } : {}
@@ -129,7 +146,7 @@ function prompt(parser, config) {
129
146
  };
130
147
  case "select": return {
131
148
  success: true,
132
- value: await (0, __inquirer_prompts.select)({
149
+ value: await prompts.select({
133
150
  message: cfg.message,
134
151
  choices: normalizeChoices(cfg.choices),
135
152
  ...cfg.default !== void 0 ? { default: cfg.default } : {}
@@ -137,7 +154,7 @@ function prompt(parser, config) {
137
154
  };
138
155
  case "rawlist": return {
139
156
  success: true,
140
- value: await (0, __inquirer_prompts.rawlist)({
157
+ value: await prompts.rawlist({
141
158
  message: cfg.message,
142
159
  choices: normalizeChoices(cfg.choices),
143
160
  ...cfg.default !== void 0 ? { default: cfg.default } : {}
@@ -145,7 +162,7 @@ function prompt(parser, config) {
145
162
  };
146
163
  case "expand": return {
147
164
  success: true,
148
- value: await (0, __inquirer_prompts.expand)({
165
+ value: await prompts.expand({
149
166
  message: cfg.message,
150
167
  choices: cfg.choices,
151
168
  ...cfg.default !== void 0 ? { default: cfg.default } : {}
@@ -153,7 +170,7 @@ function prompt(parser, config) {
153
170
  };
154
171
  case "checkbox": return {
155
172
  success: true,
156
- value: await (0, __inquirer_prompts.checkbox)({
173
+ value: await prompts.checkbox({
157
174
  message: cfg.message,
158
175
  choices: normalizeChoices(cfg.choices)
159
176
  })
package/dist/index.js CHANGED
@@ -3,6 +3,22 @@ import { annotationKey, getAnnotations } from "@optique/core/annotations";
3
3
  import { message } from "@optique/core/message";
4
4
 
5
5
  //#region src/index.ts
6
+ const promptFunctionsOverrideSymbol = Symbol.for("@optique/inquirer/prompt-functions");
7
+ const defaultPromptFunctions = {
8
+ confirm,
9
+ number,
10
+ input,
11
+ password,
12
+ editor,
13
+ select,
14
+ rawlist,
15
+ expand,
16
+ checkbox
17
+ };
18
+ function getPromptFunctions() {
19
+ const override = globalThis[promptFunctionsOverrideSymbol];
20
+ return override ?? defaultPromptFunctions;
21
+ }
6
22
  /**
7
23
  * Wraps a parser with an interactive Inquirer.js prompt fallback.
8
24
  *
@@ -44,6 +60,7 @@ function prompt(parser, config) {
44
60
  const promptBindInitialState = new PromptBindInitialStateClass();
45
61
  let promptCache = null;
46
62
  async function executePrompt() {
63
+ const prompts = getPromptFunctions();
47
64
  if ("prompter" in cfg && cfg.prompter != null) {
48
65
  const value = await cfg.prompter();
49
66
  if (cfg.type === "number" && value === void 0) return {
@@ -58,13 +75,13 @@ function prompt(parser, config) {
58
75
  switch (cfg.type) {
59
76
  case "confirm": return {
60
77
  success: true,
61
- value: await confirm({
78
+ value: await prompts.confirm({
62
79
  message: cfg.message,
63
80
  ...cfg.default !== void 0 ? { default: cfg.default } : {}
64
81
  })
65
82
  };
66
83
  case "number": {
67
- const numResult = await number({
84
+ const numResult = await prompts.number({
68
85
  message: cfg.message,
69
86
  ...cfg.default !== void 0 ? { default: cfg.default } : {},
70
87
  ...cfg.min !== void 0 ? { min: cfg.min } : {},
@@ -82,7 +99,7 @@ function prompt(parser, config) {
82
99
  }
83
100
  case "input": return {
84
101
  success: true,
85
- value: await input({
102
+ value: await prompts.input({
86
103
  message: cfg.message,
87
104
  ...cfg.default !== void 0 ? { default: cfg.default } : {},
88
105
  ...cfg.validate !== void 0 ? { validate: cfg.validate } : {}
@@ -90,7 +107,7 @@ function prompt(parser, config) {
90
107
  };
91
108
  case "password": return {
92
109
  success: true,
93
- value: await password({
110
+ value: await prompts.password({
94
111
  message: cfg.message,
95
112
  ...cfg.mask !== void 0 ? { mask: cfg.mask } : {},
96
113
  ...cfg.validate !== void 0 ? { validate: cfg.validate } : {}
@@ -98,7 +115,7 @@ function prompt(parser, config) {
98
115
  };
99
116
  case "editor": return {
100
117
  success: true,
101
- value: await editor({
118
+ value: await prompts.editor({
102
119
  message: cfg.message,
103
120
  ...cfg.default !== void 0 ? { default: cfg.default } : {},
104
121
  ...cfg.validate !== void 0 ? { validate: cfg.validate } : {}
@@ -106,7 +123,7 @@ function prompt(parser, config) {
106
123
  };
107
124
  case "select": return {
108
125
  success: true,
109
- value: await select({
126
+ value: await prompts.select({
110
127
  message: cfg.message,
111
128
  choices: normalizeChoices(cfg.choices),
112
129
  ...cfg.default !== void 0 ? { default: cfg.default } : {}
@@ -114,7 +131,7 @@ function prompt(parser, config) {
114
131
  };
115
132
  case "rawlist": return {
116
133
  success: true,
117
- value: await rawlist({
134
+ value: await prompts.rawlist({
118
135
  message: cfg.message,
119
136
  choices: normalizeChoices(cfg.choices),
120
137
  ...cfg.default !== void 0 ? { default: cfg.default } : {}
@@ -122,7 +139,7 @@ function prompt(parser, config) {
122
139
  };
123
140
  case "expand": return {
124
141
  success: true,
125
- value: await expand({
142
+ value: await prompts.expand({
126
143
  message: cfg.message,
127
144
  choices: cfg.choices,
128
145
  ...cfg.default !== void 0 ? { default: cfg.default } : {}
@@ -130,7 +147,7 @@ function prompt(parser, config) {
130
147
  };
131
148
  case "checkbox": return {
132
149
  success: true,
133
- value: await checkbox({
150
+ value: await prompts.checkbox({
134
151
  message: cfg.message,
135
152
  choices: normalizeChoices(cfg.choices)
136
153
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/inquirer",
3
- "version": "1.0.0-dev.479+a619f71b",
3
+ "version": "1.0.0-dev.487+3c38bb65",
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.479+a619f71b"
59
+ "@optique/core": "1.0.0-dev.487+3c38bb65"
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.479+a619f71b"
65
+ "@optique/env": "1.0.0-dev.487+3c38bb65"
66
66
  },
67
67
  "scripts": {
68
68
  "build": "tsdown",