instant-cli 1.0.23-branch-codex-cli-args-combinators.25401805358.1 → 1.0.23-branch-codex-cli-args-combinators.25402394638.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.
- package/.turbo/turbo-build.log +1 -1
- package/__tests__/args.test.ts +108 -125
- package/__tests__/oauthMock.ts +1 -2
- package/dist/commands/auth/client/add.d.ts.map +1 -1
- package/dist/commands/auth/client/add.js +21 -50
- package/dist/commands/auth/client/add.js.map +1 -1
- package/dist/commands/auth/client/update.d.ts.map +1 -1
- package/dist/commands/auth/client/update.js +37 -70
- package/dist/commands/auth/client/update.js.map +1 -1
- package/dist/commands/auth/origin/add.d.ts.map +1 -1
- package/dist/commands/auth/origin/add.js +4 -8
- package/dist/commands/auth/origin/add.js.map +1 -1
- package/dist/lib/args.d.ts +15 -13
- package/dist/lib/args.d.ts.map +1 -1
- package/dist/lib/args.js +25 -33
- package/dist/lib/args.js.map +1 -1
- package/dist/lib/oauth.d.ts.map +1 -1
- package/dist/lib/oauth.js +1 -2
- package/dist/lib/oauth.js.map +1 -1
- package/package.json +4 -4
- package/src/commands/auth/client/add.ts +57 -74
- package/src/commands/auth/client/update.ts +112 -130
- package/src/commands/auth/origin/add.ts +4 -8
- package/src/lib/args.ts +29 -50
- package/src/lib/oauth.ts +1 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> instant-cli@1.0.23-branch-codex-cli-args-combinators.
|
|
2
|
+
> instant-cli@1.0.23-branch-codex-cli-args-combinators.25402394638.1 build /home/runner/work/instant/instant/client/packages/cli
|
|
3
3
|
> rm -rf dist; tsc -p tsconfig.build.json
|
|
4
4
|
|
package/__tests__/args.test.ts
CHANGED
|
@@ -30,17 +30,19 @@ const basePrompt = { prompt: 'Client ID:' } as any;
|
|
|
30
30
|
|
|
31
31
|
describe('types', () => {
|
|
32
32
|
test('required return type accounts for inactive args', () => {
|
|
33
|
-
const requiredValue = Args.
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const requiredValue = Args.text(
|
|
34
|
+
{ 'client-id': 'abc123' },
|
|
35
|
+
'client-id',
|
|
36
|
+
).pipe(Args.required());
|
|
36
37
|
|
|
37
38
|
expectTypeOf(requiredValue).toEqualTypeOf<
|
|
38
39
|
Effect.Effect<string, BadArgsError>
|
|
39
40
|
>();
|
|
40
41
|
|
|
41
|
-
const conditionallyRequiredValue = Args.
|
|
42
|
-
.
|
|
43
|
-
|
|
42
|
+
const conditionallyRequiredValue = Args.text({}, 'client-id').pipe(
|
|
43
|
+
Args.availableWhen(false),
|
|
44
|
+
Args.required(),
|
|
45
|
+
);
|
|
44
46
|
|
|
45
47
|
expectTypeOf(conditionallyRequiredValue).toEqualTypeOf<
|
|
46
48
|
Effect.Effect<string | undefined, BadArgsError>
|
|
@@ -51,17 +53,17 @@ describe('types', () => {
|
|
|
51
53
|
describe('availableWhen', () => {
|
|
52
54
|
test('unavailable + value provided -> error', async () => {
|
|
53
55
|
const err = await runFail(
|
|
54
|
-
Args.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
Args.text(
|
|
57
|
+
{
|
|
58
|
+
'custom-redirect-uri': 'https://mysite.com/callback',
|
|
59
|
+
},
|
|
60
|
+
'custom-redirect-uri',
|
|
61
|
+
).pipe(
|
|
62
|
+
Args.availableWhen(false, {
|
|
63
|
+
message: 'Provided custom redirect URI when not using web app type.',
|
|
64
|
+
}),
|
|
65
|
+
Args.optional(),
|
|
66
|
+
),
|
|
65
67
|
false,
|
|
66
68
|
);
|
|
67
69
|
|
|
@@ -72,15 +74,12 @@ describe('availableWhen', () => {
|
|
|
72
74
|
|
|
73
75
|
test('unavailable + empty value provided -> error', async () => {
|
|
74
76
|
const err = await runFail(
|
|
75
|
-
Args.
|
|
76
|
-
.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}),
|
|
82
|
-
Args.optional(),
|
|
83
|
-
),
|
|
77
|
+
Args.text({ 'custom-redirect-uri': '' }, 'custom-redirect-uri').pipe(
|
|
78
|
+
Args.availableWhen(false, {
|
|
79
|
+
message: 'Provided custom redirect URI when not using web app type.',
|
|
80
|
+
}),
|
|
81
|
+
Args.optional(),
|
|
82
|
+
),
|
|
84
83
|
false,
|
|
85
84
|
);
|
|
86
85
|
|
|
@@ -91,9 +90,10 @@ describe('availableWhen', () => {
|
|
|
91
90
|
|
|
92
91
|
test('unavailable + no value -> undefined', async () => {
|
|
93
92
|
const result = await run(
|
|
94
|
-
Args.
|
|
95
|
-
.
|
|
96
|
-
|
|
93
|
+
Args.text({}, 'custom-redirect-uri').pipe(
|
|
94
|
+
Args.availableWhen(false),
|
|
95
|
+
Args.optional(),
|
|
96
|
+
),
|
|
97
97
|
false,
|
|
98
98
|
);
|
|
99
99
|
|
|
@@ -104,16 +104,14 @@ describe('availableWhen', () => {
|
|
|
104
104
|
describe('validate', () => {
|
|
105
105
|
test('valid value -> passes through', async () => {
|
|
106
106
|
const result = await run(
|
|
107
|
-
Args.
|
|
108
|
-
.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
? 'Project ID cannot include underscores.'
|
|
113
|
-
: undefined,
|
|
114
|
-
),
|
|
115
|
-
Args.required(),
|
|
107
|
+
Args.text({ 'project-id': 'my-project' }, 'project-id').pipe(
|
|
108
|
+
Args.validate((value) =>
|
|
109
|
+
value.includes('_')
|
|
110
|
+
? 'Project ID cannot include underscores.'
|
|
111
|
+
: undefined,
|
|
116
112
|
),
|
|
113
|
+
Args.required(),
|
|
114
|
+
),
|
|
117
115
|
true,
|
|
118
116
|
);
|
|
119
117
|
|
|
@@ -122,16 +120,14 @@ describe('validate', () => {
|
|
|
122
120
|
|
|
123
121
|
test('invalid value -> error', async () => {
|
|
124
122
|
const err = await runFail(
|
|
125
|
-
Args.
|
|
126
|
-
.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
? 'Project ID cannot include underscores.'
|
|
131
|
-
: undefined,
|
|
132
|
-
),
|
|
133
|
-
Args.required(),
|
|
123
|
+
Args.text({ 'project-id': 'my_project' }, 'project-id').pipe(
|
|
124
|
+
Args.validate((value) =>
|
|
125
|
+
value.includes('_')
|
|
126
|
+
? 'Project ID cannot include underscores.'
|
|
127
|
+
: undefined,
|
|
134
128
|
),
|
|
129
|
+
Args.required(),
|
|
130
|
+
),
|
|
135
131
|
true,
|
|
136
132
|
);
|
|
137
133
|
|
|
@@ -142,9 +138,7 @@ describe('validate', () => {
|
|
|
142
138
|
describe('non-interactive', () => {
|
|
143
139
|
test('required missing value -> error', async () => {
|
|
144
140
|
const err = await runFail(
|
|
145
|
-
Args.
|
|
146
|
-
.text('client-id')
|
|
147
|
-
.pipe(Args.prompt(basePrompt), Args.required()),
|
|
141
|
+
Args.text({}, 'client-id').pipe(Args.prompt(basePrompt), Args.required()),
|
|
148
142
|
true,
|
|
149
143
|
);
|
|
150
144
|
|
|
@@ -153,7 +147,7 @@ describe('non-interactive', () => {
|
|
|
153
147
|
|
|
154
148
|
test('number value -> stringified', async () => {
|
|
155
149
|
const result = await run(
|
|
156
|
-
Args.
|
|
150
|
+
Args.text({ 'client-id': 42 }, 'client-id').pipe(Args.required()),
|
|
157
151
|
true,
|
|
158
152
|
);
|
|
159
153
|
|
|
@@ -162,7 +156,7 @@ describe('non-interactive', () => {
|
|
|
162
156
|
|
|
163
157
|
test('non-string/number value -> error', async () => {
|
|
164
158
|
const err = await runFail(
|
|
165
|
-
Args.
|
|
159
|
+
Args.text({ 'client-id': true }, 'client-id').pipe(Args.required()),
|
|
166
160
|
true,
|
|
167
161
|
);
|
|
168
162
|
|
|
@@ -171,9 +165,10 @@ describe('non-interactive', () => {
|
|
|
171
165
|
|
|
172
166
|
test('valid string -> trimmed value', async () => {
|
|
173
167
|
const result = await run(
|
|
174
|
-
Args.
|
|
175
|
-
|
|
176
|
-
|
|
168
|
+
Args.text(
|
|
169
|
+
{ 'client-id': ' abc123.apps.googleusercontent.com ' },
|
|
170
|
+
'client-id',
|
|
171
|
+
).pipe(Args.required()),
|
|
177
172
|
true,
|
|
178
173
|
);
|
|
179
174
|
|
|
@@ -182,36 +177,29 @@ describe('non-interactive', () => {
|
|
|
182
177
|
|
|
183
178
|
test('optional missing value -> undefined', async () => {
|
|
184
179
|
const result = await run(
|
|
185
|
-
Args.
|
|
180
|
+
Args.text({}, 'custom-redirect-uri').pipe(Args.optional()),
|
|
186
181
|
true,
|
|
187
182
|
);
|
|
188
183
|
|
|
189
184
|
expect(result).toBeUndefined();
|
|
190
185
|
});
|
|
191
186
|
|
|
192
|
-
test('flag
|
|
193
|
-
const result = await run(
|
|
194
|
-
Args.from({ 'client-id': 'abc123' })
|
|
195
|
-
.text('--client-id')
|
|
196
|
-
.pipe(Args.required()),
|
|
197
|
-
true,
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
expect(result).toBe('abc123');
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
test('camelCase key reads camelCase opts and derives kebab-case flag name', async () => {
|
|
187
|
+
test('simpleName overrides display flag without changing lookup key', async () => {
|
|
204
188
|
const result = await run(
|
|
205
|
-
Args.
|
|
206
|
-
.
|
|
207
|
-
|
|
189
|
+
Args.text(
|
|
190
|
+
{ customRedirectUri: 'https://example.com/callback' },
|
|
191
|
+
'customRedirectUri',
|
|
192
|
+
{ simpleName: '--custom-redirect-uri' },
|
|
193
|
+
).pipe(Args.required()),
|
|
208
194
|
true,
|
|
209
195
|
);
|
|
210
196
|
|
|
211
197
|
expect(result).toBe('https://example.com/callback');
|
|
212
198
|
|
|
213
199
|
const err = await runFail(
|
|
214
|
-
Args.
|
|
200
|
+
Args.text({}, 'customRedirectUri', {
|
|
201
|
+
simpleName: '--custom-redirect-uri',
|
|
202
|
+
}).pipe(Args.required()),
|
|
215
203
|
true,
|
|
216
204
|
);
|
|
217
205
|
|
|
@@ -220,31 +208,26 @@ describe('non-interactive', () => {
|
|
|
220
208
|
);
|
|
221
209
|
});
|
|
222
210
|
|
|
223
|
-
test('
|
|
224
|
-
const result = await run(
|
|
225
|
-
Args.from({ firebaseProject: 'valid-app-123' })
|
|
226
|
-
.text('firebaseProject', { simpleName: '--project-id' })
|
|
227
|
-
.pipe(Args.required()),
|
|
228
|
-
true,
|
|
229
|
-
);
|
|
230
|
-
|
|
231
|
-
expect(result).toBe('valid-app-123');
|
|
232
|
-
|
|
211
|
+
test('does not fall back to other key shapes', async () => {
|
|
233
212
|
const err = await runFail(
|
|
234
|
-
Args.
|
|
235
|
-
|
|
236
|
-
|
|
213
|
+
Args.text(
|
|
214
|
+
{ 'custom-redirect-uri': 'https://example.com/callback' },
|
|
215
|
+
'customRedirectUri',
|
|
216
|
+
{ simpleName: '--custom-redirect-uri' },
|
|
217
|
+
).pipe(Args.required()),
|
|
237
218
|
true,
|
|
238
219
|
);
|
|
239
220
|
|
|
240
|
-
expect(err.message).toBe(
|
|
221
|
+
expect(err.message).toBe(
|
|
222
|
+
'Missing required value for --custom-redirect-uri',
|
|
223
|
+
);
|
|
241
224
|
});
|
|
242
225
|
|
|
243
226
|
test('boolean value -> parsed', async () => {
|
|
244
227
|
const result = await run(
|
|
245
|
-
Args.
|
|
246
|
-
.
|
|
247
|
-
|
|
228
|
+
Args.bool({ 'configure-web': true }, 'configure-web').pipe(
|
|
229
|
+
Args.optional(),
|
|
230
|
+
),
|
|
248
231
|
true,
|
|
249
232
|
);
|
|
250
233
|
|
|
@@ -253,9 +236,9 @@ describe('non-interactive', () => {
|
|
|
253
236
|
|
|
254
237
|
test('boolean string value -> parsed', async () => {
|
|
255
238
|
const result = await run(
|
|
256
|
-
Args.
|
|
257
|
-
.
|
|
258
|
-
|
|
239
|
+
Args.bool({ 'configure-web': 'false' }, 'configure-web').pipe(
|
|
240
|
+
Args.optional(),
|
|
241
|
+
),
|
|
259
242
|
true,
|
|
260
243
|
);
|
|
261
244
|
|
|
@@ -264,9 +247,9 @@ describe('non-interactive', () => {
|
|
|
264
247
|
|
|
265
248
|
test('invalid boolean value -> error', async () => {
|
|
266
249
|
const err = await runFail(
|
|
267
|
-
Args.
|
|
268
|
-
.
|
|
269
|
-
|
|
250
|
+
Args.bool({ 'configure-web': 'sometimes' }, 'configure-web').pipe(
|
|
251
|
+
Args.optional(),
|
|
252
|
+
),
|
|
270
253
|
true,
|
|
271
254
|
);
|
|
272
255
|
|
|
@@ -275,15 +258,13 @@ describe('non-interactive', () => {
|
|
|
275
258
|
|
|
276
259
|
test('missing confirmation returns default value', async () => {
|
|
277
260
|
const result = await run(
|
|
278
|
-
Args.
|
|
279
|
-
.
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
Args.required(),
|
|
286
|
-
),
|
|
261
|
+
Args.bool({}, 'configure-web').pipe(
|
|
262
|
+
Args.confirm({
|
|
263
|
+
promptText: 'Configure web redirect flow?',
|
|
264
|
+
defaultValue: false,
|
|
265
|
+
}),
|
|
266
|
+
Args.required(),
|
|
267
|
+
),
|
|
287
268
|
true,
|
|
288
269
|
);
|
|
289
270
|
|
|
@@ -294,9 +275,10 @@ describe('non-interactive', () => {
|
|
|
294
275
|
describe('interactive', () => {
|
|
295
276
|
test('value already provided -> use it directly', async () => {
|
|
296
277
|
const result = await run(
|
|
297
|
-
Args.
|
|
298
|
-
|
|
299
|
-
|
|
278
|
+
Args.text(
|
|
279
|
+
{ 'client-id': ' abc123.apps.googleusercontent.com ' },
|
|
280
|
+
'client-id',
|
|
281
|
+
).pipe(Args.prompt(basePrompt), Args.required()),
|
|
300
282
|
false,
|
|
301
283
|
);
|
|
302
284
|
|
|
@@ -307,9 +289,10 @@ describe('interactive', () => {
|
|
|
307
289
|
mockPromptReturn = ' GOCSPX-secret123 ';
|
|
308
290
|
|
|
309
291
|
const result = await run(
|
|
310
|
-
Args.
|
|
311
|
-
.
|
|
312
|
-
|
|
292
|
+
Args.text({}, 'client-secret').pipe(
|
|
293
|
+
Args.prompt(basePrompt),
|
|
294
|
+
Args.required(),
|
|
295
|
+
),
|
|
313
296
|
false,
|
|
314
297
|
);
|
|
315
298
|
|
|
@@ -320,9 +303,10 @@ describe('interactive', () => {
|
|
|
320
303
|
mockPromptReturn = '';
|
|
321
304
|
|
|
322
305
|
const err = await runFail(
|
|
323
|
-
Args.
|
|
324
|
-
.
|
|
325
|
-
|
|
306
|
+
Args.text({}, 'client-secret').pipe(
|
|
307
|
+
Args.prompt(basePrompt),
|
|
308
|
+
Args.required(),
|
|
309
|
+
),
|
|
326
310
|
false,
|
|
327
311
|
);
|
|
328
312
|
|
|
@@ -333,9 +317,10 @@ describe('interactive', () => {
|
|
|
333
317
|
mockPromptReturn = '';
|
|
334
318
|
|
|
335
319
|
const result = await run(
|
|
336
|
-
Args.
|
|
337
|
-
.
|
|
338
|
-
|
|
320
|
+
Args.text({}, 'custom-redirect-uri').pipe(
|
|
321
|
+
Args.prompt(basePrompt),
|
|
322
|
+
Args.optional(),
|
|
323
|
+
),
|
|
339
324
|
false,
|
|
340
325
|
);
|
|
341
326
|
|
|
@@ -346,15 +331,13 @@ describe('interactive', () => {
|
|
|
346
331
|
mockPromptReturn = true;
|
|
347
332
|
|
|
348
333
|
const result = await run(
|
|
349
|
-
Args.
|
|
350
|
-
.
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
Args.optional(),
|
|
357
|
-
),
|
|
334
|
+
Args.bool({}, 'configure-web').pipe(
|
|
335
|
+
Args.confirm({
|
|
336
|
+
promptText: 'Configure web redirect flow?',
|
|
337
|
+
defaultValue: false,
|
|
338
|
+
}),
|
|
339
|
+
Args.optional(),
|
|
340
|
+
),
|
|
358
341
|
false,
|
|
359
342
|
);
|
|
360
343
|
|
package/__tests__/oauthMock.ts
CHANGED
|
@@ -40,13 +40,12 @@ export const makeOAuthMock = (mocks: {
|
|
|
40
40
|
providerType: string,
|
|
41
41
|
opts: Record<string, unknown>,
|
|
42
42
|
) {
|
|
43
|
-
const args = Args.from(opts);
|
|
44
43
|
const { auth, provider } = yield* getOrCreateProvider(providerType);
|
|
45
44
|
const used: Set<string> = new Set(
|
|
46
45
|
(auth.oauth_clients ?? []).map((c: any) => c.client_name),
|
|
47
46
|
);
|
|
48
47
|
const suggested = findName(providerType, used);
|
|
49
|
-
const clientName = yield*
|
|
48
|
+
const clientName = yield* Args.text(opts, 'name').pipe(
|
|
50
49
|
Args.prompt({
|
|
51
50
|
prompt: 'Client Name:',
|
|
52
51
|
defaultValue: suggested,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../../src/commands/auth/client/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAiB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGvD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AA4C5D,eAAO,MAAM,gBAAgB,gFAO5B,CAAC;
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../../src/commands/auth/client/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAiB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGvD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AA4C5D,eAAO,MAAM,gBAAgB,gFAO5B,CAAC;AAkmBF,eAAO,MAAM,gBAAgB;;;;wgBAwD5B,CAAC"}
|
|
@@ -70,9 +70,8 @@ const selectGoogleCredentialMode = Effect.fn(function* () {
|
|
|
70
70
|
});
|
|
71
71
|
const resolveGoogleCredentialMode = Effect.fn(function* ({ appType, opts, }) {
|
|
72
72
|
const { yes } = yield* GlobalOpts;
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
const hasProvidedSomeCustomCredentials = args.hasAny([
|
|
73
|
+
const devCredentialsFlag = Args.isTrue(opts, 'dev-credentials');
|
|
74
|
+
const hasProvidedSomeCustomCredentials = Args.hasAny(opts, [
|
|
76
75
|
'client-id',
|
|
77
76
|
'client-secret',
|
|
78
77
|
'custom-redirect-uri',
|
|
@@ -133,7 +132,6 @@ const printGoogleCustomCredentialsClient = Effect.fn(function* ({ appType, clien
|
|
|
133
132
|
].join('\n'), { dimBorder: true, padding: { right: 1, left: 1 } }));
|
|
134
133
|
});
|
|
135
134
|
const handleGoogleClient = Effect.fn(function* (opts) {
|
|
136
|
-
const args = Args.from(opts);
|
|
137
135
|
// This one requires special logic for getting client name
|
|
138
136
|
// because the suggested name includes the app type
|
|
139
137
|
const appType = yield* selectGoogleAppType(opts['app-type']);
|
|
@@ -145,7 +143,7 @@ const handleGoogleClient = Effect.fn(function* (opts) {
|
|
|
145
143
|
const { auth, provider } = yield* getOrCreateProvider('google');
|
|
146
144
|
const usedClientNames = new Set((auth.oauth_clients ?? []).map((client) => client.client_name));
|
|
147
145
|
const suggestedClientName = findName(`google-${appType}`, usedClientNames);
|
|
148
|
-
const clientName = yield*
|
|
146
|
+
const clientName = yield* Args.text(opts, 'name').pipe(Args.prompt({
|
|
149
147
|
prompt: 'Client Name:',
|
|
150
148
|
defaultValue: suggestedClientName,
|
|
151
149
|
placeholder: suggestedClientName,
|
|
@@ -160,16 +158,16 @@ const handleGoogleClient = Effect.fn(function* (opts) {
|
|
|
160
158
|
message: `The unique name '${clientName}' is already in use.`,
|
|
161
159
|
});
|
|
162
160
|
}
|
|
163
|
-
const clientId = yield*
|
|
161
|
+
const clientId = yield* Args.text(opts, 'client-id').pipe(Args.availableWhen(!useSharedCredentials, {
|
|
164
162
|
message: '--client-id is not compatible with --dev-credentials. Drop one or the other.',
|
|
165
163
|
}), Args.prompt(clientIdPrompt({ providerUrl: googleConsoleUrl })), Args.required());
|
|
166
164
|
const usesCustomWebCredentials = !useSharedCredentials && appType === 'web';
|
|
167
|
-
const clientSecret = yield*
|
|
165
|
+
const clientSecret = yield* Args.text(opts, 'client-secret').pipe(Args.availableWhen(usesCustomWebCredentials, {
|
|
168
166
|
message: useSharedCredentials
|
|
169
167
|
? '--client-secret is not compatible with --dev-credentials. Drop one or the other.'
|
|
170
168
|
: undefined,
|
|
171
169
|
}), Args.prompt(clientSecretPrompt({ providerUrl: googleConsoleUrl })), Args.required());
|
|
172
|
-
const customRedirectUri = yield*
|
|
170
|
+
const customRedirectUri = yield* Args.text(opts, 'custom-redirect-uri').pipe(Args.availableWhen(usesCustomWebCredentials, {
|
|
173
171
|
message: useSharedCredentials
|
|
174
172
|
? '--custom-redirect-uri is not compatible with --dev-credentials.'
|
|
175
173
|
: 'Provided custom redirect URI when not using web app type.',
|
|
@@ -208,17 +206,10 @@ const handleGoogleClient = Effect.fn(function* (opts) {
|
|
|
208
206
|
});
|
|
209
207
|
});
|
|
210
208
|
const handleGithubClient = Effect.fn(function* (opts) {
|
|
211
|
-
const args = Args.from(opts);
|
|
212
209
|
const { clientName, provider } = yield* getClientNameAndProvider('github', opts);
|
|
213
|
-
const clientId = yield*
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const clientSecret = yield* args
|
|
217
|
-
.text('client-secret')
|
|
218
|
-
.pipe(Args.prompt(clientSecretPrompt({ providerUrl: githubDeveloperUrl })), Args.required());
|
|
219
|
-
const customRedirectUri = yield* args
|
|
220
|
-
.text('custom-redirect-uri')
|
|
221
|
-
.pipe(Args.prompt(optionalRedirectPrompt), Args.optional());
|
|
210
|
+
const clientId = yield* Args.text(opts, 'client-id').pipe(Args.prompt(clientIdPrompt({ providerUrl: githubDeveloperUrl })), Args.required());
|
|
211
|
+
const clientSecret = yield* Args.text(opts, 'client-secret').pipe(Args.prompt(clientSecretPrompt({ providerUrl: githubDeveloperUrl })), Args.required());
|
|
212
|
+
const customRedirectUri = yield* Args.text(opts, 'custom-redirect-uri').pipe(Args.prompt(optionalRedirectPrompt), Args.optional());
|
|
222
213
|
const redirectUri = customRedirectUri || DEFAULT_OAUTH_CALLBACK_URL;
|
|
223
214
|
// The backend infers GitHub's authorization/token endpoints from
|
|
224
215
|
// meta.providerName === 'github', so we don't pass them here.
|
|
@@ -243,17 +234,10 @@ const handleGithubClient = Effect.fn(function* (opts) {
|
|
|
243
234
|
].join('\n'), { dimBorder: true, padding: { right: 1, left: 1 } }));
|
|
244
235
|
});
|
|
245
236
|
const handleLinkedInClient = Effect.fn(function* (opts) {
|
|
246
|
-
const args = Args.from(opts);
|
|
247
237
|
const { clientName, provider } = yield* getClientNameAndProvider('linkedin', opts);
|
|
248
|
-
const clientId = yield*
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const clientSecret = yield* args
|
|
252
|
-
.text('client-secret')
|
|
253
|
-
.pipe(Args.prompt(clientSecretPrompt({ providerUrl: linkedinDeveloperUrl })), Args.required());
|
|
254
|
-
const customRedirectUri = yield* args
|
|
255
|
-
.text('custom-redirect-uri')
|
|
256
|
-
.pipe(Args.prompt(optionalRedirectPrompt), Args.optional());
|
|
238
|
+
const clientId = yield* Args.text(opts, 'client-id').pipe(Args.prompt(clientIdPrompt({ providerUrl: linkedinDeveloperUrl })), Args.required());
|
|
239
|
+
const clientSecret = yield* Args.text(opts, 'client-secret').pipe(Args.prompt(clientSecretPrompt({ providerUrl: linkedinDeveloperUrl })), Args.required());
|
|
240
|
+
const customRedirectUri = yield* Args.text(opts, 'custom-redirect-uri').pipe(Args.prompt(optionalRedirectPrompt), Args.optional());
|
|
257
241
|
const redirectUri = customRedirectUri || DEFAULT_OAUTH_CALLBACK_URL;
|
|
258
242
|
const response = yield* addOAuthClient({
|
|
259
243
|
providerId: provider.id,
|
|
@@ -278,40 +262,33 @@ const handleLinkedInClient = Effect.fn(function* (opts) {
|
|
|
278
262
|
].join('\n'), { dimBorder: true, padding: { right: 1, left: 1 } }));
|
|
279
263
|
});
|
|
280
264
|
const handleAppleClient = Effect.fn(function* (opts) {
|
|
281
|
-
const args = Args.from(opts);
|
|
282
265
|
const { clientName, provider } = yield* getClientNameAndProvider('apple', opts);
|
|
283
|
-
const servicesId = yield*
|
|
284
|
-
.text('services-id')
|
|
285
|
-
.pipe(Args.prompt(appleServicesIdPrompt({})), Args.required());
|
|
266
|
+
const servicesId = yield* Args.text(opts, 'services-id').pipe(Args.prompt(appleServicesIdPrompt({})), Args.required());
|
|
286
267
|
// If any web-flow flag is provided, enable web flow; otherwise ask
|
|
287
268
|
// (non-interactively with --yes we default to native-only).
|
|
288
|
-
const anyWebFlagProvided =
|
|
269
|
+
const anyWebFlagProvided = Args.hasAny(opts, [
|
|
289
270
|
'team-id',
|
|
290
271
|
'key-id',
|
|
291
272
|
'private-key-file',
|
|
292
273
|
]);
|
|
293
274
|
const configureWeb = anyWebFlagProvided
|
|
294
275
|
? true
|
|
295
|
-
: yield*
|
|
276
|
+
: yield* Args.bool(opts, 'configure-web').pipe(Args.confirm({
|
|
296
277
|
promptText: 'Configure web redirect flow? ' +
|
|
297
278
|
chalk.dim('(requires Team ID, Key ID, and a .p8 private key from Apple)'),
|
|
298
279
|
defaultValue: false,
|
|
299
280
|
}), Args.required());
|
|
300
281
|
const skipWeb = !configureWeb;
|
|
301
282
|
const webSkipMessage = 'requires configuring the web redirect flow (also provide --team-id, --key-id, and --private-key-file).';
|
|
302
|
-
const teamId = yield*
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
const keyId = yield* args
|
|
306
|
-
.text('key-id')
|
|
307
|
-
.pipe(Args.availableWhen(!skipWeb, { message: `--key-id ${webSkipMessage}` }), Args.prompt(appleKeyIdPrompt({})), Args.required());
|
|
308
|
-
const privateKeyPath = yield* args.text('private-key-file').pipe(Args.availableWhen(!skipWeb, {
|
|
283
|
+
const teamId = yield* Args.text(opts, 'team-id').pipe(Args.availableWhen(!skipWeb, { message: `--team-id ${webSkipMessage}` }), Args.prompt(appleTeamIdPrompt({})), Args.required());
|
|
284
|
+
const keyId = yield* Args.text(opts, 'key-id').pipe(Args.availableWhen(!skipWeb, { message: `--key-id ${webSkipMessage}` }), Args.prompt(appleKeyIdPrompt({})), Args.required());
|
|
285
|
+
const privateKeyPath = yield* Args.text(opts, 'private-key-file').pipe(Args.availableWhen(!skipWeb, {
|
|
309
286
|
message: `--private-key-file ${webSkipMessage}`,
|
|
310
287
|
}), Args.prompt(applePrivateKeyFilePrompt({})), Args.required());
|
|
311
288
|
const privateKey = privateKeyPath
|
|
312
289
|
? yield* readPrivateKeyFile(privateKeyPath)
|
|
313
290
|
: undefined;
|
|
314
|
-
const customRedirectUri = yield*
|
|
291
|
+
const customRedirectUri = yield* Args.text(opts, 'custom-redirect-uri').pipe(Args.availableWhen(!skipWeb, {
|
|
315
292
|
message: `--custom-redirect-uri ${webSkipMessage}`,
|
|
316
293
|
}), Args.prompt(optionalRedirectPrompt), Args.optional());
|
|
317
294
|
const redirectUri = privateKey
|
|
@@ -353,11 +330,8 @@ const handleAppleClient = Effect.fn(function* (opts) {
|
|
|
353
330
|
}));
|
|
354
331
|
});
|
|
355
332
|
const handleClerkClient = Effect.fn(function* (opts) {
|
|
356
|
-
const args = Args.from(opts);
|
|
357
333
|
const { clientName, provider } = yield* getClientNameAndProvider('clerk', opts);
|
|
358
|
-
const publishableKey = yield*
|
|
359
|
-
.text('publishable-key')
|
|
360
|
-
.pipe(Args.prompt(clerkPublishableKeyPrompt({})), Args.required());
|
|
334
|
+
const publishableKey = yield* Args.text(opts, 'publishable-key').pipe(Args.prompt(clerkPublishableKeyPrompt({})), Args.required());
|
|
361
335
|
const domain = clerkDomainFromPublishableKey(publishableKey);
|
|
362
336
|
if (!domain) {
|
|
363
337
|
return yield* BadArgsError.make({
|
|
@@ -384,11 +358,8 @@ const handleClerkClient = Effect.fn(function* (opts) {
|
|
|
384
358
|
}`, { borderStyle: 'none' }));
|
|
385
359
|
});
|
|
386
360
|
const handleFirebaseClient = Effect.fn(function* (opts) {
|
|
387
|
-
const args = Args.from(opts);
|
|
388
361
|
const { clientName, provider } = yield* getClientNameAndProvider('firebase', opts);
|
|
389
|
-
const projectId = yield*
|
|
390
|
-
.text('project-id')
|
|
391
|
-
.pipe(Args.prompt(firebaseProjectIdPrompt({})), Args.validate(validateFirebaseProjectId), Args.required());
|
|
362
|
+
const projectId = yield* Args.text(opts, 'project-id').pipe(Args.prompt(firebaseProjectIdPrompt({})), Args.validate(validateFirebaseProjectId), Args.required());
|
|
392
363
|
const response = yield* addOAuthClient({
|
|
393
364
|
providerId: provider.id,
|
|
394
365
|
clientName,
|