@jacebenson/jsn 4.3.9 → 4.3.10-dev.67
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/README.md +11 -539
- package/package.json +1 -1
- package/src/auth.js +81 -38
- package/src/browser-auth.js +162 -0
- package/src/browser-launch.js +148 -0
- package/src/capabilities.js +10 -0
- package/src/cli.js +2 -2
- package/src/commands/auth.js +763 -650
- package/src/commands/flows.js +17 -7
- package/src/commands/midservers.js +1 -1
- package/src/commands/setup.js +25 -20
- package/src/commands/skill.js +1 -1
- package/src/commands/skipped-updates.js +1 -1
- package/src/commands/updatesets.js +14 -2
- package/src/errors.js +8 -0
- package/src/flow-create.js +329 -74
- package/src/flow-designer-interactive.js +11 -6
- package/src/flow-safe-edit.js +48 -0
- package/src/paginated-search.js +2 -2
- package/src/prompts.js +43 -0
package/src/prompts.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as prompts from '@inquirer/prompts';
|
|
2
|
+
|
|
3
|
+
export class PromptCancelled extends Error {
|
|
4
|
+
constructor() {
|
|
5
|
+
super('Cancelled.');
|
|
6
|
+
this.name = 'PromptCancelled';
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Add Escape cancellation to an Inquirer prompt without changing its answers. */
|
|
11
|
+
export function cancellablePrompt(prompt) {
|
|
12
|
+
return async (config, context = {}) => {
|
|
13
|
+
const input = context.input || process.stdin;
|
|
14
|
+
const controller = new AbortController();
|
|
15
|
+
const onKey = (_value, key) => {
|
|
16
|
+
if (key?.name === 'escape') controller.abort(new PromptCancelled());
|
|
17
|
+
};
|
|
18
|
+
input.on('keypress', onKey);
|
|
19
|
+
try {
|
|
20
|
+
return await prompt({ ...config, message: `${config.message} (Esc to cancel)` }, {
|
|
21
|
+
...context,
|
|
22
|
+
signal: context.signal ? AbortSignal.any([context.signal, controller.signal]) : controller.signal,
|
|
23
|
+
});
|
|
24
|
+
} catch (error) {
|
|
25
|
+
if (controller.signal.aborted) throw controller.signal.reason;
|
|
26
|
+
throw error;
|
|
27
|
+
} finally {
|
|
28
|
+
input.removeListener('keypress', onKey);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const input = cancellablePrompt(prompts.input);
|
|
34
|
+
export const password = cancellablePrompt(prompts.password);
|
|
35
|
+
export const select = cancellablePrompt(prompts.select);
|
|
36
|
+
export const search = cancellablePrompt(prompts.search);
|
|
37
|
+
export const confirm = cancellablePrompt(prompts.confirm);
|
|
38
|
+
export const checkbox = cancellablePrompt(prompts.checkbox);
|
|
39
|
+
|
|
40
|
+
// The editor prompt hands the keyboard to $EDITOR, so Escape belongs to that
|
|
41
|
+
// editor. It lives here so every command imports prompts from one module;
|
|
42
|
+
// cancelling an editor still uses Inquirer's Ctrl+C abort.
|
|
43
|
+
export const editor = prompts.editor;
|