@pokit/prompter-clack 0.0.1
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/LICENSE +21 -0
- package/README.md +57 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/prompter.d.ts +11 -0
- package/dist/prompter.d.ts.map +1 -0
- package/dist/prompter.js +58 -0
- package/package.json +59 -0
- package/src/index.ts +8 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Daniel Grant
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @pokit/prompter-clack
|
|
2
|
+
|
|
3
|
+
Interactive prompts adapter for pok using [Clack](https://github.com/natemoo-re/clack).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @pokit/prompter-clack
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { run } from '@pokit/core';
|
|
15
|
+
import { createPrompter } from '@pokit/prompter-clack';
|
|
16
|
+
|
|
17
|
+
await run(args, {
|
|
18
|
+
prompter: createPrompter(),
|
|
19
|
+
// ...
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- Text input prompts
|
|
26
|
+
- Password/secret input
|
|
27
|
+
- Confirmation prompts
|
|
28
|
+
- Select menus (single choice)
|
|
29
|
+
- Multi-select menus
|
|
30
|
+
|
|
31
|
+
## What It Does
|
|
32
|
+
|
|
33
|
+
When a command defines required context fields that aren't provided via flags, pok uses the prompter to interactively request them:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
export const command = defineCommand({
|
|
37
|
+
context: {
|
|
38
|
+
env: {
|
|
39
|
+
from: 'flag',
|
|
40
|
+
schema: z.enum(['dev', 'staging', 'prod']),
|
|
41
|
+
description: 'Target environment',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
run: async (r, ctx) => {
|
|
45
|
+
// If --env not provided, prompter asks user to select
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
$ mycli deploy
|
|
52
|
+
? Select environment > dev / staging / prod
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Documentation
|
|
56
|
+
|
|
57
|
+
See the [full documentation](https://github.com/openpok/pok/blob/main/docs/packages/prompter-clack.md).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clack Prompter Implementation
|
|
3
|
+
*
|
|
4
|
+
* Implements the Prompter interface using @clack/prompts.
|
|
5
|
+
*/
|
|
6
|
+
import type { Prompter } from '@pokit/core';
|
|
7
|
+
/**
|
|
8
|
+
* Create a Prompter using @clack/prompts
|
|
9
|
+
*/
|
|
10
|
+
export declare function createPrompter(): Prompter;
|
|
11
|
+
//# sourceMappingURL=prompter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompter.d.ts","sourceRoot":"","sources":["../src/prompter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,QAAQ,EAKT,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,wBAAgB,cAAc,IAAI,QAAQ,CA2DzC"}
|
package/dist/prompter.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clack Prompter Implementation
|
|
3
|
+
*
|
|
4
|
+
* Implements the Prompter interface using @clack/prompts.
|
|
5
|
+
*/
|
|
6
|
+
import * as p from '@clack/prompts';
|
|
7
|
+
/**
|
|
8
|
+
* Create a Prompter using @clack/prompts
|
|
9
|
+
*/
|
|
10
|
+
export function createPrompter() {
|
|
11
|
+
return {
|
|
12
|
+
async select(options) {
|
|
13
|
+
const result = await p.select({
|
|
14
|
+
message: options.message,
|
|
15
|
+
options: options.options,
|
|
16
|
+
initialValue: options.initialValue,
|
|
17
|
+
});
|
|
18
|
+
if (p.isCancel(result)) {
|
|
19
|
+
process.exit(0);
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
},
|
|
23
|
+
async multiselect(options) {
|
|
24
|
+
const result = await p.multiselect({
|
|
25
|
+
message: options.message,
|
|
26
|
+
options: options.options,
|
|
27
|
+
initialValues: options.initialValues,
|
|
28
|
+
required: options.required,
|
|
29
|
+
});
|
|
30
|
+
if (p.isCancel(result)) {
|
|
31
|
+
process.exit(0);
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
},
|
|
35
|
+
async confirm(options) {
|
|
36
|
+
const result = await p.confirm({
|
|
37
|
+
message: options.message,
|
|
38
|
+
initialValue: options.initialValue,
|
|
39
|
+
});
|
|
40
|
+
if (p.isCancel(result)) {
|
|
41
|
+
process.exit(0);
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
},
|
|
45
|
+
async text(options) {
|
|
46
|
+
const result = await p.text({
|
|
47
|
+
message: options.message,
|
|
48
|
+
placeholder: options.placeholder,
|
|
49
|
+
initialValue: options.initialValue,
|
|
50
|
+
validate: options.validate,
|
|
51
|
+
});
|
|
52
|
+
if (p.isCancel(result)) {
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pokit/prompter-clack",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Clack-based prompter adapter for pok CLI applications",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cli",
|
|
7
|
+
"command-line",
|
|
8
|
+
"typescript",
|
|
9
|
+
"bun",
|
|
10
|
+
"terminal",
|
|
11
|
+
"pok",
|
|
12
|
+
"pokjs",
|
|
13
|
+
"clack",
|
|
14
|
+
"prompts",
|
|
15
|
+
"interactive",
|
|
16
|
+
"input"
|
|
17
|
+
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/notation-dev/openpok.git",
|
|
23
|
+
"directory": "packages/prompter-clack"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/notation-dev/openpok#readme",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/notation-dev/openpok/issues"
|
|
28
|
+
},
|
|
29
|
+
"main": "./src/index.ts",
|
|
30
|
+
"module": "./src/index.ts",
|
|
31
|
+
"types": "./src/index.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"bun": "./src/index.ts",
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"import": "./dist/index.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"README.md",
|
|
42
|
+
"LICENSE"
|
|
43
|
+
],
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@clack/prompts": "^0.11.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/bun": "latest"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"@pokit/core": "0.0.1"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"bun": ">=1.0.0"
|
|
58
|
+
}
|
|
59
|
+
}
|