Skip to content

Commit 232c31d

Browse files
committed
chore: rename builder to workflow
1 parent 3742b91 commit 232c31d

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

.changeset/red-walls-greet.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
'@clack/prompts': minor
33
---
44

5-
add prompt `builder`
5+
add prompt `workflow` builder

examples/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"basic": "jiti ./basic.ts",
1313
"spinner": "jiti ./spinner.ts",
1414
"changesets": "jiti ./changesets.ts",
15-
"builder": "jiti ./builder.ts"
15+
"workflow": "jiti ./workflow.ts"
1616
},
1717
"devDependencies": {
1818
"jiti": "^1.17.0"

examples/builder.ts renamed to examples/workflow.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import * as p from '@clack/prompts';
22

33
(async () => {
44
const results = await p
5-
.builder()
6-
.add('path', () =>
5+
.workflow()
6+
.step('path', () =>
77
p.text({
88
message: 'Where should we create your project?',
99
placeholder: './sparkling-solid',
@@ -13,7 +13,7 @@ import * as p from '@clack/prompts';
1313
},
1414
})
1515
)
16-
.add('password', () =>
16+
.step('password', () =>
1717
p.password({
1818
message: 'Provide a password',
1919
validate: (value) => {
@@ -22,7 +22,7 @@ import * as p from '@clack/prompts';
2222
},
2323
})
2424
)
25-
.add('type', ({ results }) =>
25+
.step('type', ({ results }) =>
2626
p.select({
2727
message: `Pick a project type within "${results.path}"`,
2828
initialValue: 'ts',
@@ -37,7 +37,7 @@ import * as p from '@clack/prompts';
3737
],
3838
})
3939
)
40-
.add('tools', () =>
40+
.step('tools', () =>
4141
p.multiselect({
4242
message: 'Select additional tools.',
4343
initialValues: ['prettier', 'eslint'],
@@ -49,7 +49,7 @@ import * as p from '@clack/prompts';
4949
],
5050
})
5151
)
52-
.add('install', ({ results }) =>
52+
.step('install', ({ results }) =>
5353
p.confirm({
5454
message: 'Install dependencies?',
5555
initialValue: false,
@@ -58,11 +58,11 @@ import * as p from '@clack/prompts';
5858
.run();
5959

6060
await p
61-
.builder()
62-
.add('cancel', () => p.text({ message: 'Try cancel prompt (Ctrl + C):' }))
63-
.add('afterCancel', () => p.text({ message: 'This will not appear!' }))
61+
.workflow()
62+
.step('cancel', () => p.text({ message: 'Try cancel prompt (Ctrl + C):' }))
63+
.step('afterCancel', () => p.text({ message: 'This will not appear!' }))
6464
.onCancel(({ results }) => {
65-
p.cancel('Builder canceled');
65+
p.cancel('Workflow canceled');
6666
process.exit(0);
6767
})
6868
.run();

packages/prompts/README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ s.stop('Installed via npm');
123123

124124
## Utilities
125125

126-
### Grouping
126+
### Group
127127

128128
Grouping prompts together is a great way to keep your code organized. This accepts a JSON object with a name that can be used to reference the group later. The second argument is an optional but has a `onCancel` callback that will be called if the user cancels one of the prompts in the group.
129129

@@ -157,18 +157,18 @@ const group = await p.group(
157157
console.log(group.name, group.age, group.color);
158158
```
159159

160-
### Building
160+
### Workflow
161161

162-
Just like `group`, but on `builder` way, so you can choose which one fits better.
162+
Just like `group`, but on builder way, so you can choose which one fits better.
163163

164164
```js
165165
import * as p from '@clack/prompts';
166166

167167
const results = await p
168-
.builder()
169-
.add('name', () => p.text({ message: 'What is your name?' }))
170-
.add('age', () => p.text({ message: 'What is your age?' }))
171-
.add('color', ({ results }) =>
168+
.workflow()
169+
.step('name', () => p.text({ message: 'What is your name?' }))
170+
.step('age', () => p.text({ message: 'What is your age?' }))
171+
.step('color', ({ results }) =>
172172
p.multiselect({
173173
message: `What is your favorite color ${results.name}?`,
174174
options: [
@@ -179,7 +179,7 @@ const results = await p
179179
})
180180
)
181181
.onCancel(() => {
182-
p.cancel('Builder canceled');
182+
p.cancel('Workflow canceled');
183183
process.exit(0);
184184
})
185185
.run();

packages/prompts/src/index.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -770,32 +770,32 @@ export const group = async <T>(
770770
return results;
771771
};
772772

773-
type NextPromptBuilder<
773+
type NextWorkflowBuilder<
774774
TResults extends Record<string, unknown>,
775775
TKey extends string,
776776
TResult
777-
> = PromptBuilder<
777+
> = WorkflowBuilder<
778778
{
779779
[Key in keyof TResults]: Key extends TKey ? TResult : TResults[Key];
780780
} & {
781781
[Key in TKey]: TResult;
782782
}
783783
>;
784784

785-
class PromptBuilder<TResults extends Record<string, unknown> = {}> {
785+
class WorkflowBuilder<TResults extends Record<string, unknown> = {}> {
786786
private results: TResults = {} as TResults;
787787
private prompts: Record<string, PromptWithOptions<TResults, unknown>> = {};
788788
private cancelCallback: PromptWithOptions<Partial<TResults>, void> | undefined;
789789

790-
public add<TKey extends string, TResult>(
790+
public step<TKey extends string, TResult>(
791791
key: TKey extends keyof TResults ? never : TKey,
792792
prompt: PromptWithOptions<TResults, TResult>
793-
): NextPromptBuilder<TResults, TKey, TResult> {
793+
): NextWorkflowBuilder<TResults, TKey, TResult> {
794794
this.prompts[key] = prompt;
795-
return this as NextPromptBuilder<TResults, TKey, TResult>;
795+
return this as NextWorkflowBuilder<TResults, TKey, TResult>;
796796
}
797797

798-
public onCancel(cb: PromptWithOptions<Partial<TResults>, void>): PromptBuilder<TResults> {
798+
public onCancel(cb: PromptWithOptions<Partial<TResults>, void>): WorkflowBuilder<TResults> {
799799
this.cancelCallback = cb;
800800
return this;
801801
}
@@ -814,6 +814,6 @@ class PromptBuilder<TResults extends Record<string, unknown> = {}> {
814814
}
815815
}
816816

817-
export const builder = () => {
818-
return new PromptBuilder();
817+
export const workflow = () => {
818+
return new WorkflowBuilder();
819819
};

0 commit comments

Comments
 (0)