@simplysf/simply-plugin-kit 1.0.11 → 1.1.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,2 +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';
package/lib/index.js CHANGED
@@ -15,4 +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
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"}
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"}
@@ -0,0 +1,36 @@
1
+ /** One choice in a {@link select} prompt. */
2
+ export type SelectOption<T> = {
3
+ value: T;
4
+ /** The text shown for the option. Defaults to `String(value)`. */
5
+ label?: string;
6
+ /** Extra text shown beside the option while it is highlighted. */
7
+ hint?: string;
8
+ };
9
+ export type SelectPromptOptions<T> = {
10
+ message: string;
11
+ options: Array<SelectOption<T>>;
12
+ initialValue?: T;
13
+ /** How many options to show at once before the list scrolls. */
14
+ maxItems?: number;
15
+ };
16
+ export type ConfirmPromptOptions = {
17
+ message: string;
18
+ /** How long to wait for an answer before resolving `defaultAnswer`. Defaults to 10 seconds. */
19
+ ms?: number;
20
+ defaultAnswer?: boolean;
21
+ };
22
+ /**
23
+ * Ask the user to pick one option.
24
+ *
25
+ * @returns The `value` of the chosen option.
26
+ * @throws {SfError} `PromptCancelledError` if the user cancels (Ctrl+C / Esc).
27
+ */
28
+ export declare function select<T>({ message, options, initialValue, maxItems }: SelectPromptOptions<T>): Promise<T>;
29
+ /**
30
+ * Ask a yes/no question. Same contract as `SfCommand.confirm()`: if nobody answers within `ms`, it
31
+ * resolves `defaultAnswer`, so an unattended run declines instead of hanging.
32
+ *
33
+ * @returns The user's answer, or `defaultAnswer` on timeout.
34
+ * @throws {SfError} `PromptCancelledError` if the user cancels (Ctrl+C / Esc).
35
+ */
36
+ export declare function confirm({ message, ms, defaultAnswer }: ConfirmPromptOptions): Promise<boolean>;
@@ -0,0 +1,58 @@
1
+ /*
2
+ * Copyright (c) 2026, SimplySF.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import * as clack from '@clack/prompts';
17
+ import { Messages } from '@salesforce/core';
18
+ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
19
+ const messages = Messages.loadMessages('@simplysf/simply-plugin-kit', 'simply.plugin-kit');
20
+ /**
21
+ * Ask the user to pick one option.
22
+ *
23
+ * @returns The `value` of the chosen option.
24
+ * @throws {SfError} `PromptCancelledError` if the user cancels (Ctrl+C / Esc).
25
+ */
26
+ export async function select({ message, options, initialValue, maxItems }) {
27
+ const answer = await clack.select({
28
+ message,
29
+ // clack's Option<T> type is conditional on T being a primitive; ours is the common shape of both branches.
30
+ options: options,
31
+ initialValue,
32
+ maxItems,
33
+ });
34
+ if (clack.isCancel(answer)) {
35
+ throw messages.createError('error.promptCancelled');
36
+ }
37
+ return answer;
38
+ }
39
+ /**
40
+ * Ask a yes/no question. Same contract as `SfCommand.confirm()`: if nobody answers within `ms`, it
41
+ * resolves `defaultAnswer`, so an unattended run declines instead of hanging.
42
+ *
43
+ * @returns The user's answer, or `defaultAnswer` on timeout.
44
+ * @throws {SfError} `PromptCancelledError` if the user cancels (Ctrl+C / Esc).
45
+ */
46
+ export async function confirm({ message, ms = 10_000, defaultAnswer = false }) {
47
+ const signal = AbortSignal.timeout(ms);
48
+ const answer = await clack.confirm({ message, initialValue: defaultAnswer, signal });
49
+ if (clack.isCancel(answer)) {
50
+ // clack reports an aborted prompt as a cancel; the signal says which one it was.
51
+ if (signal.aborted) {
52
+ return defaultAnswer;
53
+ }
54
+ throw messages.createError('error.promptCancelled');
55
+ }
56
+ return answer;
57
+ }
58
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/prompts/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC;AA0B3F;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAI,EAAE,OAAO,EAAE,OAAO,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"}
@@ -1,3 +1,7 @@
1
1
  # error.targetOrgConnectionFailed
2
2
 
3
3
  Unable to establish connection to the org.
4
+
5
+ # error.promptCancelled
6
+
7
+ Prompt cancelled.
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.0.11",
4
+ "version": "1.1.0",
5
5
  "author": "@ClayChipps",
6
6
  "homepage": "https://github.com/SimplySF/simply-plugins",
7
7
  "bugs": "https://github.com/SimplySF/simply-plugins/issues",
@@ -30,6 +30,7 @@
30
30
  "exports": "./lib/index.js",
31
31
  "type": "module",
32
32
  "dependencies": {
33
+ "@clack/prompts": "^1.8.1",
33
34
  "@oclif/core": "^4.11.2",
34
35
  "@salesforce/core": "^8.30.0",
35
36
  "@salesforce/sf-plugins-core": "^12.2.16"
@@ -124,5 +125,5 @@
124
125
  "output": []
125
126
  }
126
127
  },
127
- "gitHead": "37a20f64434ed8a208f43503c6bbc6e68d25ca0d"
128
+ "gitHead": "923ef3cd7465256951925ff6c41948b351dce9e2"
128
129
  }