Skip to content

Commit 9539f89

Browse files
cpreston321orochaa
authored andcommitted
feat: changes
1 parent 25d70a2 commit 9539f89

File tree

4 files changed

+54
-21
lines changed

4 files changed

+54
-21
lines changed

examples/index.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import * as p from '@clack/prompts';
2+
import color from 'picocolors';
3+
4+
(async () => {
5+
console.clear();
6+
7+
p.intro(`${color.bgCyan(color.black(' clack-examples '))}`);
8+
9+
// Choose example to run
10+
const example = await p.select({
11+
message: 'Choose an example:',
12+
options: [
13+
{ label: 'Basic', value: 'basic', hint: 'basic project setup' },
14+
{ label: 'Changesets', value: 'changesets', hint: 'mimics the changesets cli' },
15+
{ label: 'Spinner', value: 'spinner', hint: 'shows off the spinner functionality' },
16+
{ label: 'Workflow', value: 'workflow' },
17+
],
18+
});
19+
20+
if (p.isCancel(example)) return;
21+
22+
try {
23+
// Run example
24+
process.stdout.write('\n');
25+
await import(`./${example}.ts`);
26+
} catch (error) {
27+
// Don't crash on error
28+
}
29+
})();

examples/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"picocolors": "^1.0.0"
1010
},
1111
"scripts": {
12+
"start": "jiti ./index.ts",
1213
"basic": "jiti ./basic.ts",
1314
"spinner": "jiti ./spinner.ts",
1415
"spinner-ci": "npx cross-env CI=\"true\" jiti ./spinner-ci.ts",

examples/workflow.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,29 @@ import * as p from '@clack/prompts';
2727
)
2828
.step('fork', ({ results }) => {
2929
if (results.install === true) {
30-
return p.workflow().step('package', () =>
31-
p.select({
32-
message: 'Pick a package manager:',
33-
initialValue: 'pnpm',
34-
options: [
35-
{
36-
label: 'npm',
37-
value: 'npm',
38-
},
39-
{
40-
label: 'yarn',
41-
value: 'yarn',
42-
},
43-
{
44-
label: 'pnpm',
45-
value: 'pnpm',
46-
},
47-
],
48-
})
49-
).run();
30+
return p
31+
.workflow()
32+
.step('package', () =>
33+
p.select({
34+
message: 'Pick a package manager:',
35+
initialValue: 'pnpm',
36+
options: [
37+
{
38+
label: 'npm',
39+
value: 'npm',
40+
},
41+
{
42+
label: 'yarn',
43+
value: 'yarn',
44+
},
45+
{
46+
label: 'pnpm',
47+
value: 'pnpm',
48+
},
49+
],
50+
})
51+
)
52+
.run();
5053
}
5154
})
5255
.run();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"private": true,
44
"type": "module",
55
"scripts": {
6+
"dev": "pnpm --filter @clack/examples run start",
67
"stub": "pnpm -r run build --stub",
78
"build": "pnpm --filter \"@clack/*\" run build",
89
"start": "pnpm run dev",
9-
"dev": "pnpm --filter @example/changesets run start",
1010
"format": "biome check --write",
1111
"lint": "biome lint --write --unsafe",
1212
"type-check": "biome lint && tsc",

0 commit comments

Comments
 (0)