Repository navigation
Commit 34cb5a3
authored
fix(setup): pull simulations by their single-type alias in the wizard (#92)
## Value
**V.A.L.U.E. tier:** micro. It restores intended behavior in about 50 changed lines across 4 files, and a deterministic test proves it.
- **Problem:** in the interactive `npm run setup` wizard, choosing simulations fails with "Single-resource pull requires exactly one resource type". Setup stops before simulations, suites and evals are downloaded, and the org folder is left half set up. It happens to anyone whose org has simulations and who picks "All".
- **Who it affects:** new users connecting an org through the wizard, including everyone who runs [`npx create-vapi-app`](https://www.npmjs.com/package/create-vapi-app), which hands off to it. Non-interactive setup (`npm run setup -- <org>`) does one full pull and was never affected.
## How it works
The wizard pulls what you pick one type at a time: `pull.ts <org> --force --type <type> --id …`. It passed the internal type name. But `simulations` is also the `--type` group alias for `personalities`, `scenarios`, `simulations` and `simulationSuites`, and a pull by `--id` refuses more than one type.
- **`src/resource-type-args.ts` (new, config-free):** the group and path alias maps and `resolveResourceTypes` move here from `config.ts` unchanged, so tests can import them. `config.ts` parses argv and exits on import, so tests couldn't. A new `typeArgFor(type)` returns the `--type` spelling that resolves to exactly that type; for `simulations` that's `simulations/tests`.
- **`src/setup.ts`:** the wizard's per-type pull passes `typeArgFor(typeKey)`.
- **`tests/resource-type-args.test.ts`:** checks that every resource type comes back as exactly itself through `typeArgFor`, so a future type that collides with a group alias fails CI. It also checks that `--type simulations` still selects all four types for `apply`.
## Verification
**Before:** on `main`, run the exact command the wizard builds against an org with simulations:
```
tsx src/pull.ts <org> --force --skip-bindings --type simulations --id <sim-id>
❌ Pull failed: Single-resource pull requires exactly one resource type.
```
**After:** run it with `typeArgFor("simulations")`, which gives `--type simulations/tests`:
```
Found 2 matching simulations in Vapi (requested 2)
✨ … -> resources/<org>/simulations/tests/….yml
simulations: 2 new, 0 updated
```
The wizard's per-type pulls for `simulationSuites` and `evals` also completed, scoped to the requested ids. Your run had never reached them. These were read-only pulls against a real org, into a throwaway copy of the repo.
`npm run build` passes, and `npm test` passes 584/584.
## Not in this PR
Each per-type pull in the wizard prints the `--force` warning ("run `npm run pull` (no flag) first…") and waits 2 seconds. For an org with all 9 types, that's 9 warnings and about 18 seconds of waiting, for advice aimed at hand-run `--force` pulls. It could be a follow-up to suppress the warning for the wizard's own pulls.
🤖 Generated with [Claude Code](https://claude.com/claude-code)4 files changed
Lines changed: 110 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 22 | + | |
| 23 | + | |
39 | 24 | | |
40 | 25 | | |
41 | 26 | | |
| |||
67 | 52 | | |
68 | 53 | | |
69 | 54 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | 55 | | |
93 | 56 | | |
94 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
348 | 349 | | |
349 | 350 | | |
350 | 351 | | |
351 | | - | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
352 | 355 | | |
353 | 356 | | |
354 | 357 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
0 commit comments