@simplysf/simply-plugin-kit 1.1.0 → 1.2.0

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/lib/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { targetOrgFlags } from './flags/orgFlags.js';
2
2
  export { requireConnection, type TargetOrgFlagValues } from './org/requireConnection.js';
3
- export { confirm, select, type ConfirmPromptOptions, type SelectOption, type SelectPromptOptions, } from './prompts/prompts.js';
3
+ export { confirm, select, text, type ConfirmPromptOptions, type SelectOption, type SelectPromptOptions, type TextPromptOptions, } from './prompts/prompts.js';
package/lib/index.js CHANGED
@@ -15,5 +15,5 @@
15
15
  */
16
16
  export { targetOrgFlags } from './flags/orgFlags.js';
17
17
  export { requireConnection } from './org/requireConnection.js';
18
- export { confirm, select, } from './prompts/prompts.js';
18
+ export { confirm, select, text, } from './prompts/prompts.js';
19
19
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAA4B,MAAM,4BAA4B,CAAC;AACzF,OAAO,EACL,OAAO,EACP,MAAM,GAIP,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAA4B,MAAM,4BAA4B,CAAC;AACzF,OAAO,EACL,OAAO,EACP,MAAM,EACN,IAAI,GAKL,MAAM,sBAAsB,CAAC"}
@@ -19,6 +19,27 @@ export type ConfirmPromptOptions = {
19
19
  ms?: number;
20
20
  defaultAnswer?: boolean;
21
21
  };
22
+ export type TextPromptOptions = {
23
+ message: string;
24
+ /** Shown in the empty field as a hint. Not returned. */
25
+ placeholder?: string;
26
+ /** Pre-filled, editable answer. */
27
+ initialValue?: string;
28
+ /**
29
+ * Checks the trimmed answer. Return a message to show and ask again, or `undefined` to accept it.
30
+ * An empty answer is refused unless `allowEmpty` is set.
31
+ */
32
+ validate?: (value: string) => string | undefined;
33
+ /** Accept an empty answer. Defaults to `false`. */
34
+ allowEmpty?: boolean;
35
+ };
36
+ /**
37
+ * Ask the user to type a single line.
38
+ *
39
+ * @returns The answer, trimmed.
40
+ * @throws {SfError} `PromptCancelledError` if the user cancels (Ctrl+C / Esc).
41
+ */
42
+ export declare function text({ message, placeholder, initialValue, validate, allowEmpty, }: TextPromptOptions): Promise<string>;
22
43
  /**
23
44
  * Ask the user to pick one option.
24
45
  *
@@ -17,6 +17,30 @@ import * as clack from '@clack/prompts';
17
17
  import { Messages } from '@salesforce/core';
18
18
  Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
19
19
  const messages = Messages.loadMessages('@simplysf/simply-plugin-kit', 'simply.plugin-kit');
20
+ /**
21
+ * Ask the user to type a single line.
22
+ *
23
+ * @returns The answer, trimmed.
24
+ * @throws {SfError} `PromptCancelledError` if the user cancels (Ctrl+C / Esc).
25
+ */
26
+ export async function text({ message, placeholder, initialValue, validate, allowEmpty = false, }) {
27
+ const answer = await clack.text({
28
+ message,
29
+ placeholder,
30
+ initialValue,
31
+ validate: (value) => {
32
+ const trimmed = (value ?? '').trim();
33
+ if (!trimmed && !allowEmpty) {
34
+ return messages.getMessage('prompt.required');
35
+ }
36
+ return validate?.(trimmed);
37
+ },
38
+ });
39
+ if (clack.isCancel(answer)) {
40
+ throw messages.createError('error.promptCancelled');
41
+ }
42
+ return answer.trim();
43
+ }
20
44
  /**
21
45
  * Ask the user to pick one option.
22
46
  *
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/prompts/prompts.ts"],"names":[],"mappings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AO,EAAE,YAAY,EAAE,QAAQ,EAA0B;IAClG,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,CAAI;QACnC,OAAO;QACP,2GAA2G;QAC3G,OAAO,EAAE,OAA2D;QACpE,YAAY;QACZ,QAAQ;KACT,CAAC,CAAC;IACH,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,MAAM,QAAQ,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,EAAE,OAAO,EAAE,EAAE,GAAG,MAAM,EAAE,aAAa,GAAG,KAAK,EAAwB;IACjG,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC;IACrF,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,iFAAiF;QACjF,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,OAAO,aAAa,CAAC;QACvB,CAAC;QACD,MAAM,QAAQ,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -5,3 +5,7 @@ Unable to establish connection to the org.
5
5
  # error.promptCancelled
6
6
 
7
7
  Prompt cancelled.
8
+
9
+ # prompt.required
10
+
11
+ An answer is required.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@simplysf/simply-plugin-kit",
3
3
  "description": "Shared oclif command building blocks for SimplySF Salesforce CLI plugins",
4
- "version": "1.1.0",
4
+ "version": "1.2.0",
5
5
  "author": "@ClayChipps",
6
6
  "homepage": "https://github.com/SimplySF/simply-plugins",
7
7
  "bugs": "https://github.com/SimplySF/simply-plugins/issues",
@@ -125,5 +125,5 @@
125
125
  "output": []
126
126
  }
127
127
  },
128
- "gitHead": "923ef3cd7465256951925ff6c41948b351dce9e2"
128
+ "gitHead": "37ad65c53848845230f4d40a4ef513ab935f09ef"
129
129
  }