create-spud 0.1.2 → 0.1.4

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.
Files changed (3) hide show
  1. package/index.ts +14 -11
  2. package/package.json +1 -1
  3. package/readme.md +1 -1
package/index.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import { mkdir, readdir } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
- import { intro, outro, cancel, text, confirm, tasks, group, multiselect } from "@clack/prompts";
5
+ import { intro, note, cancel, text, confirm, tasks, group, multiselect } from "@clack/prompts";
6
6
  import kebabcase from "lodash.kebabcase";
7
7
 
8
8
  intro("It's spud time.");
@@ -20,14 +20,16 @@ const { rawGameName, features, shouldContinue } = await group(
20
20
  rawGameName: () =>
21
21
  text({
22
22
  message: "Game name",
23
- placeholder: "eg. Space Invaders",
23
+ placeholder: "e.g. Space Invaders",
24
24
  validate(value) {
25
- if (!value?.trim()) return "Game name is required. Esc to cancel.";
25
+ const trimmed = value?.trim();
26
+ if (!trimmed) return "Game name is required. Esc to cancel.";
27
+ if (!kebabcase(trimmed)) return "Game name must include letters or numbers.";
26
28
  },
27
29
  }),
28
30
  features: () =>
29
31
  multiselect({
30
- message: "Features",
32
+ message: "Select features",
31
33
  initialValues: [],
32
34
  required: false,
33
35
  options: [
@@ -38,7 +40,7 @@ const { rawGameName, features, shouldContinue } = await group(
38
40
  }),
39
41
  shouldContinue: ({ results }) =>
40
42
  confirm({
41
- message: `We'll create a folder for "${kebabcase((results.rawGameName ?? "").trim())}" in the current directory. Do you want to continue?`,
43
+ message: `Create a folder for "${kebabcase((results.rawGameName ?? "").trim())}" in the current directory?`,
42
44
  }),
43
45
  },
44
46
  {
@@ -50,7 +52,7 @@ const { rawGameName, features, shouldContinue } = await group(
50
52
  );
51
53
 
52
54
  if (!shouldContinue) {
53
- cancel("Operation cancelled.");
55
+ cancel("Cancelled.");
54
56
  process.exit(0);
55
57
  }
56
58
 
@@ -71,16 +73,17 @@ await tasks([
71
73
  {
72
74
  title: "Installing dependencies with Bun",
73
75
  async task() {
74
- const proc = Bun.spawn(["bun", "install"], {
75
- cwd: targetDir,
76
- });
77
- await proc.exited;
76
+ const proc = Bun.spawn(["bun", "install"], { cwd: targetDir });
77
+ const exitCode = await proc.exited;
78
+ if (exitCode !== 0) {
79
+ throw new Error(`bun install failed with exit code ${exitCode}`);
80
+ }
78
81
  return "Installed via bun";
79
82
  },
80
83
  },
81
84
  ]);
82
85
 
83
- outro(`You're all set! Now: cd ${slug} && bun dev`);
86
+ note(`cd ${slug}\nbun dev`, "Next steps");
84
87
 
85
88
  async function copyDir(
86
89
  sourceDir: string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-spud",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "bin": {
5
5
  "create-spud": "./index.ts"
6
6
  },
package/readme.md CHANGED
@@ -8,7 +8,7 @@ The quickest way to set up and scaffold a [spud](https://spud.gg) game.
8
8
  bun create spud
9
9
  ```
10
10
 
11
- ![demo](./demo.svg)
11
+ ![cli usage demo](https://spud.gg/images/demo.svg)
12
12
 
13
13
  ## What gets created
14
14