instant-cli 1.0.23 → 1.0.24-branch-codex-cli-args-combinators.25405829034.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.
Files changed (43) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/__tests__/args.test.ts +358 -0
  3. package/__tests__/authClientAddApple.test.ts +9 -10
  4. package/__tests__/authClientAddClerk.test.ts +6 -5
  5. package/__tests__/authClientAddGithub.test.ts +6 -5
  6. package/__tests__/authClientAddGoogle.test.ts +5 -4
  7. package/__tests__/authClientAddLinkedin.test.ts +6 -5
  8. package/__tests__/oauthMock.ts +8 -9
  9. package/dist/commands/auth/client/add.d.ts.map +1 -1
  10. package/dist/commands/auth/client/add.js +53 -167
  11. package/dist/commands/auth/client/add.js.map +1 -1
  12. package/dist/commands/auth/client/shared.d.ts +0 -4
  13. package/dist/commands/auth/client/shared.d.ts.map +1 -1
  14. package/dist/commands/auth/client/shared.js +0 -4
  15. package/dist/commands/auth/client/shared.js.map +1 -1
  16. package/dist/commands/auth/client/update.d.ts +1 -1
  17. package/dist/commands/auth/client/update.d.ts.map +1 -1
  18. package/dist/commands/auth/client/update.js +25 -112
  19. package/dist/commands/auth/client/update.js.map +1 -1
  20. package/dist/commands/auth/origin/add.d.ts.map +1 -1
  21. package/dist/commands/auth/origin/add.js +37 -59
  22. package/dist/commands/auth/origin/add.js.map +1 -1
  23. package/dist/lib/args.d.ts +212 -0
  24. package/dist/lib/args.d.ts.map +1 -0
  25. package/dist/lib/args.js +313 -0
  26. package/dist/lib/args.js.map +1 -0
  27. package/dist/lib/oauth.d.ts +2 -2
  28. package/dist/lib/oauth.d.ts.map +1 -1
  29. package/dist/lib/oauth.js +13 -17
  30. package/dist/lib/oauth.js.map +1 -1
  31. package/dist/lib/ui.d.ts +0 -18
  32. package/dist/lib/ui.d.ts.map +1 -1
  33. package/dist/lib/ui.js +0 -76
  34. package/dist/lib/ui.js.map +1 -1
  35. package/package.json +4 -4
  36. package/src/commands/auth/client/add.ts +114 -180
  37. package/src/commands/auth/client/shared.ts +0 -12
  38. package/src/commands/auth/client/update.ts +85 -139
  39. package/src/commands/auth/origin/add.ts +25 -36
  40. package/src/lib/args.ts +453 -0
  41. package/src/lib/oauth.ts +8 -14
  42. package/src/lib/ui.ts +0 -127
  43. package/__tests__/optOrPrompt.test.ts +0 -229
@@ -1,229 +0,0 @@
1
- import { test, expect, describe, vi } from 'vitest';
2
- import { Effect, Layer } from 'effect';
3
- import { optOrPrompt } from '../src/lib/ui.ts';
4
- import { GlobalOpts } from '../src/context/globalOpts.ts';
5
-
6
- // -- helpers --
7
-
8
- const run = (
9
- effect: Effect.Effect<string | undefined, any, GlobalOpts>,
10
- yes: boolean,
11
- ) =>
12
- Effect.runPromise(
13
- effect.pipe(Effect.provide(Layer.succeed(GlobalOpts, { yes }))),
14
- );
15
-
16
- const runFail = (
17
- effect: Effect.Effect<string | undefined, any, GlobalOpts>,
18
- yes: boolean,
19
- ) =>
20
- Effect.runPromise(
21
- effect.pipe(
22
- Effect.flip,
23
- Effect.provide(Layer.succeed(GlobalOpts, { yes })),
24
- ),
25
- );
26
-
27
- // Mock renderUnwrap so we never touch real TTY.
28
- let mockPromptReturn = '';
29
- vi.mock('../src/ui/lib.ts', async (importOriginal) => {
30
- const orig: any = await importOriginal();
31
- return {
32
- ...orig,
33
- renderUnwrap: () => Promise.resolve(mockPromptReturn),
34
- };
35
- });
36
-
37
- const basePrompt = { prompt: 'Client ID:' } as any;
38
-
39
- // -- skipIf gate --
40
-
41
- describe('skipIf gate', () => {
42
- test('skipIf=true + value provided → error', async () => {
43
- const err = await runFail(
44
- optOrPrompt('https://mysite.com/callback', {
45
- required: false,
46
- simpleName: '--custom-redirect-uri',
47
- skipIf: true,
48
- skipMessage:
49
- 'Provided custom redirect URI when not using web app type.',
50
- prompt: basePrompt,
51
- }),
52
- false,
53
- );
54
- expect(err.message).toBe(
55
- 'Provided custom redirect URI when not using web app type.',
56
- );
57
- });
58
-
59
- test('skipIf=true + no value → undefined', async () => {
60
- const result = await run(
61
- optOrPrompt(undefined, {
62
- required: false,
63
- simpleName: '--custom-redirect-uri',
64
- skipIf: true,
65
- prompt: basePrompt,
66
- }),
67
- false,
68
- );
69
- expect(result).toBeUndefined();
70
- });
71
- });
72
-
73
- // -- non-interactive (yes=true) --
74
-
75
- describe('non-interactive (yes=true)', () => {
76
- describe('required=true', () => {
77
- test('no value → error', async () => {
78
- const err = await runFail(
79
- optOrPrompt(undefined, {
80
- required: true,
81
- simpleName: '--client-id',
82
- skipIf: false,
83
- prompt: basePrompt,
84
- }),
85
- true,
86
- );
87
- expect(err.message).toBe('Missing required value for --client-id');
88
- });
89
-
90
- test('number value → stringified', async () => {
91
- const result = await run(
92
- optOrPrompt(42, {
93
- required: true,
94
- simpleName: '--client-id',
95
- skipIf: false,
96
- prompt: basePrompt,
97
- }),
98
- true,
99
- );
100
- expect(result).toBe('42');
101
- });
102
-
103
- test('non-string/number value → error', async () => {
104
- const err = await runFail(
105
- optOrPrompt(true, {
106
- required: true,
107
- simpleName: '--client-id',
108
- skipIf: false,
109
- prompt: basePrompt,
110
- }),
111
- true,
112
- );
113
- expect(err.message).toBe('Invalid value for --client-id');
114
- });
115
-
116
- test('valid string → trimmed value', async () => {
117
- const result = await run(
118
- optOrPrompt(' abc123.apps.googleusercontent.com ', {
119
- required: true,
120
- simpleName: '--client-id',
121
- skipIf: false,
122
- prompt: basePrompt,
123
- }),
124
- true,
125
- );
126
- expect(result).toBe('abc123.apps.googleusercontent.com');
127
- });
128
- });
129
-
130
- describe('required=false', () => {
131
- test('no value → undefined', async () => {
132
- const result = await run(
133
- optOrPrompt(undefined, {
134
- required: false,
135
- simpleName: '--custom-redirect-uri',
136
- skipIf: false,
137
- prompt: basePrompt,
138
- }),
139
- true,
140
- );
141
- expect(result).toBeUndefined();
142
- });
143
-
144
- test('non-string/number value → error', async () => {
145
- const err = await runFail(
146
- optOrPrompt(true, {
147
- required: false,
148
- simpleName: '--custom-redirect-uri',
149
- skipIf: false,
150
- prompt: basePrompt,
151
- }),
152
- true,
153
- );
154
- expect(err.message).toBe('Invalid value for --custom-redirect-uri');
155
- });
156
-
157
- test('valid string → trimmed value', async () => {
158
- const result = await run(
159
- optOrPrompt(' https://mysite.com/oauth/callback ', {
160
- required: false,
161
- simpleName: '--custom-redirect-uri',
162
- skipIf: false,
163
- prompt: basePrompt,
164
- }),
165
- true,
166
- );
167
- expect(result).toBe('https://mysite.com/oauth/callback');
168
- });
169
- });
170
- });
171
-
172
- // -- interactive (yes=false) --
173
-
174
- describe('interactive (yes=false)', () => {
175
- test('value already provided → use it directly', async () => {
176
- const result = await run(
177
- optOrPrompt(' abc123.apps.googleusercontent.com ', {
178
- required: true,
179
- simpleName: '--client-id',
180
- skipIf: false,
181
- prompt: basePrompt,
182
- }),
183
- false,
184
- );
185
- expect(result).toBe('abc123.apps.googleusercontent.com');
186
- });
187
-
188
- test('no value + user types a value → trimmed result', async () => {
189
- mockPromptReturn = ' GOCSPX-secret123 ';
190
- const result = await run(
191
- optOrPrompt(undefined, {
192
- required: true,
193
- simpleName: '--client-secret',
194
- skipIf: false,
195
- prompt: basePrompt,
196
- }),
197
- false,
198
- );
199
- expect(result).toBe('GOCSPX-secret123');
200
- });
201
-
202
- test('no value + user enters empty + required → error', async () => {
203
- mockPromptReturn = '';
204
- const err = await runFail(
205
- optOrPrompt(undefined, {
206
- required: true,
207
- simpleName: '--client-secret',
208
- skipIf: false,
209
- prompt: basePrompt,
210
- }),
211
- false,
212
- );
213
- expect(err.message).toBe('Missing required value for --client-secret');
214
- });
215
-
216
- test('no value + user enters empty + optional → undefined', async () => {
217
- mockPromptReturn = '';
218
- const result = await run(
219
- optOrPrompt(undefined, {
220
- required: false,
221
- simpleName: '--custom-redirect-uri',
222
- skipIf: false,
223
- prompt: basePrompt,
224
- }),
225
- false,
226
- );
227
- expect(result).toBeUndefined();
228
- });
229
- });