@beezer-pet/instant-cli 0.0.0-stage → 1.0.67-beezer.3
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 +4 -0
- package/LICENSE.md +202 -0
- package/README.md +34 -2
- package/__tests__/appCommands.test.ts +228 -0
- package/__tests__/args.test.ts +358 -0
- package/__tests__/auth.test.ts +128 -0
- package/__tests__/authClientAddApple.test.ts +376 -0
- package/__tests__/authClientAddClerk.test.ts +222 -0
- package/__tests__/authClientAddGithub.test.ts +245 -0
- package/__tests__/authClientAddGoogle.test.ts +373 -0
- package/__tests__/authClientAddLinkedin.test.ts +262 -0
- package/__tests__/authClientList.test.ts +90 -0
- package/__tests__/authClientUpdate.test.ts +583 -0
- package/__tests__/authOriginManagement.test.ts +308 -0
- package/__tests__/backupDownload.test.ts +206 -0
- package/__tests__/backups.test.ts +221 -0
- package/__tests__/config.test.ts +57 -0
- package/__tests__/e2e/cli.e2e.test.ts +1267 -0
- package/__tests__/e2e/helpers.ts +177 -0
- package/__tests__/effectHelpers.ts +45 -0
- package/__tests__/mergeSchema.test.ts +197 -0
- package/__tests__/multiSelect.test.ts +236 -0
- package/__tests__/oauthMock.ts +76 -0
- package/__tests__/promptOk.test.ts +44 -0
- package/__tests__/redirectUriPrompt.test.ts +40 -0
- package/__tests__/sdkInstallSpec.test.ts +36 -0
- package/__tests__/select.test.ts +224 -0
- package/__tests__/webhooks.test.ts +728 -0
- package/bin/index.js +3 -0
- package/dist/auth/index.d.ts +4 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +103 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/commands/app/delete.d.ts +7 -0
- package/dist/commands/app/delete.d.ts.map +1 -0
- package/dist/commands/app/delete.js +57 -0
- package/dist/commands/app/delete.js.map +1 -0
- package/dist/commands/app/list.d.ts +6 -0
- package/dist/commands/app/list.d.ts.map +1 -0
- package/dist/commands/app/list.js +29 -0
- package/dist/commands/app/list.js.map +1 -0
- package/dist/commands/auth/client/add.d.ts +9 -0
- package/dist/commands/auth/client/add.d.ts.map +1 -0
- package/dist/commands/auth/client/add.js +409 -0
- package/dist/commands/auth/client/add.js.map +1 -0
- package/dist/commands/auth/client/delete.d.ts +11 -0
- package/dist/commands/auth/client/delete.d.ts.map +1 -0
- package/dist/commands/auth/client/delete.js +48 -0
- package/dist/commands/auth/client/delete.js.map +1 -0
- package/dist/commands/auth/client/list.d.ts +6 -0
- package/dist/commands/auth/client/list.d.ts.map +1 -0
- package/dist/commands/auth/client/list.js +38 -0
- package/dist/commands/auth/client/list.js.map +1 -0
- package/dist/commands/auth/client/shared.d.ts +70 -0
- package/dist/commands/auth/client/shared.d.ts.map +1 -0
- package/dist/commands/auth/client/shared.js +140 -0
- package/dist/commands/auth/client/shared.js.map +1 -0
- package/dist/commands/auth/client/update.d.ts +8 -0
- package/dist/commands/auth/client/update.d.ts.map +1 -0
- package/dist/commands/auth/client/update.js +445 -0
- package/dist/commands/auth/client/update.js.map +1 -0
- package/dist/commands/auth/email/pull.d.ts +24 -0
- package/dist/commands/auth/email/pull.d.ts.map +1 -0
- package/dist/commands/auth/email/pull.js +100 -0
- package/dist/commands/auth/email/pull.js.map +1 -0
- package/dist/commands/auth/email/push.d.ts +8 -0
- package/dist/commands/auth/email/push.d.ts.map +1 -0
- package/dist/commands/auth/email/push.js +58 -0
- package/dist/commands/auth/email/push.js.map +1 -0
- package/dist/commands/auth/email/resend.d.ts +3 -0
- package/dist/commands/auth/email/resend.d.ts.map +1 -0
- package/dist/commands/auth/email/resend.js +7 -0
- package/dist/commands/auth/email/resend.js.map +1 -0
- package/dist/commands/auth/email/reset.d.ts +5 -0
- package/dist/commands/auth/email/reset.d.ts.map +1 -0
- package/dist/commands/auth/email/reset.js +25 -0
- package/dist/commands/auth/email/reset.js.map +1 -0
- package/dist/commands/auth/email/status.d.ts +57 -0
- package/dist/commands/auth/email/status.d.ts.map +1 -0
- package/dist/commands/auth/email/status.js +96 -0
- package/dist/commands/auth/email/status.js.map +1 -0
- package/dist/commands/auth/email/verify.d.ts +5 -0
- package/dist/commands/auth/email/verify.d.ts.map +1 -0
- package/dist/commands/auth/email/verify.js +12 -0
- package/dist/commands/auth/email/verify.js.map +1 -0
- package/dist/commands/auth/origin/add.d.ts +12 -0
- package/dist/commands/auth/origin/add.d.ts.map +1 -0
- package/dist/commands/auth/origin/add.js +153 -0
- package/dist/commands/auth/origin/add.js.map +1 -0
- package/dist/commands/auth/origin/delete.d.ts +8 -0
- package/dist/commands/auth/origin/delete.d.ts.map +1 -0
- package/dist/commands/auth/origin/delete.js +38 -0
- package/dist/commands/auth/origin/delete.js.map +1 -0
- package/dist/commands/auth/origin/list.d.ts +9 -0
- package/dist/commands/auth/origin/list.d.ts.map +1 -0
- package/dist/commands/auth/origin/list.js +52 -0
- package/dist/commands/auth/origin/list.js.map +1 -0
- package/dist/commands/backup/download.d.ts +10 -0
- package/dist/commands/backup/download.d.ts.map +1 -0
- package/dist/commands/backup/download.js +174 -0
- package/dist/commands/backup/download.js.map +1 -0
- package/dist/commands/backup/list.d.ts +11 -0
- package/dist/commands/backup/list.d.ts.map +1 -0
- package/dist/commands/backup/list.js +74 -0
- package/dist/commands/backup/list.js.map +1 -0
- package/dist/commands/claim.d.ts +6 -0
- package/dist/commands/claim.d.ts.map +1 -0
- package/dist/commands/claim.js +22 -0
- package/dist/commands/claim.js.map +1 -0
- package/dist/commands/explorer.d.ts +6 -0
- package/dist/commands/explorer.d.ts.map +1 -0
- package/dist/commands/explorer.js +13 -0
- package/dist/commands/explorer.js.map +1 -0
- package/dist/commands/info.d.ts +9 -0
- package/dist/commands/info.d.ts.map +1 -0
- package/dist/commands/info.js +41 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +41 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/initWithoutFiles.d.ts +6 -0
- package/dist/commands/initWithoutFiles.d.ts.map +1 -0
- package/dist/commands/initWithoutFiles.js +64 -0
- package/dist/commands/initWithoutFiles.js.map +1 -0
- package/dist/commands/login.d.ts +9 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +44 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +3 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +14 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/pull.d.ts +5 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +15 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/commands/push.d.ts +6 -0
- package/dist/commands/push.d.ts.map +1 -0
- package/dist/commands/push.js +20 -0
- package/dist/commands/push.js.map +1 -0
- package/dist/commands/query.d.ts +7 -0
- package/dist/commands/query.d.ts.map +1 -0
- package/dist/commands/query.js +52 -0
- package/dist/commands/query.js.map +1 -0
- package/dist/commands/webhooks/add.d.ts +9 -0
- package/dist/commands/webhooks/add.d.ts.map +1 -0
- package/dist/commands/webhooks/add.js +75 -0
- package/dist/commands/webhooks/add.js.map +1 -0
- package/dist/commands/webhooks/delete.d.ts +6 -0
- package/dist/commands/webhooks/delete.d.ts.map +1 -0
- package/dist/commands/webhooks/delete.js +17 -0
- package/dist/commands/webhooks/delete.js.map +1 -0
- package/dist/commands/webhooks/disable.d.ts +7 -0
- package/dist/commands/webhooks/disable.d.ts.map +1 -0
- package/dist/commands/webhooks/disable.js +18 -0
- package/dist/commands/webhooks/disable.js.map +1 -0
- package/dist/commands/webhooks/enable.d.ts +6 -0
- package/dist/commands/webhooks/enable.d.ts.map +1 -0
- package/dist/commands/webhooks/enable.js +18 -0
- package/dist/commands/webhooks/enable.js.map +1 -0
- package/dist/commands/webhooks/events/list.d.ts +7 -0
- package/dist/commands/webhooks/events/list.d.ts.map +1 -0
- package/dist/commands/webhooks/events/list.js +31 -0
- package/dist/commands/webhooks/events/list.js.map +1 -0
- package/dist/commands/webhooks/events/payload.d.ts +8 -0
- package/dist/commands/webhooks/events/payload.d.ts.map +1 -0
- package/dist/commands/webhooks/events/payload.js +39 -0
- package/dist/commands/webhooks/events/payload.js.map +1 -0
- package/dist/commands/webhooks/events/resend.d.ts +8 -0
- package/dist/commands/webhooks/events/resend.d.ts.map +1 -0
- package/dist/commands/webhooks/events/resend.js +43 -0
- package/dist/commands/webhooks/events/resend.js.map +1 -0
- package/dist/commands/webhooks/list.d.ts +8 -0
- package/dist/commands/webhooks/list.d.ts.map +1 -0
- package/dist/commands/webhooks/list.js +29 -0
- package/dist/commands/webhooks/list.js.map +1 -0
- package/dist/commands/webhooks/shared.d.ts +40 -0
- package/dist/commands/webhooks/shared.d.ts.map +1 -0
- package/dist/commands/webhooks/shared.js +248 -0
- package/dist/commands/webhooks/shared.js.map +1 -0
- package/dist/commands/webhooks/update.d.ts +10 -0
- package/dist/commands/webhooks/update.d.ts.map +1 -0
- package/dist/commands/webhooks/update.js +189 -0
- package/dist/commands/webhooks/update.js.map +1 -0
- package/dist/context/authToken.d.ts +29 -0
- package/dist/context/authToken.d.ts.map +1 -0
- package/dist/context/authToken.js +73 -0
- package/dist/context/authToken.js.map +1 -0
- package/dist/context/currentApp.d.ts +38 -0
- package/dist/context/currentApp.d.ts.map +1 -0
- package/dist/context/currentApp.js +222 -0
- package/dist/context/currentApp.js.map +1 -0
- package/dist/context/globalOpts.d.ts +11 -0
- package/dist/context/globalOpts.d.ts.map +1 -0
- package/dist/context/globalOpts.js +13 -0
- package/dist/context/globalOpts.js.map +1 -0
- package/dist/context/platformApi.d.ts +19 -0
- package/dist/context/platformApi.d.ts.map +1 -0
- package/dist/context/platformApi.js +24 -0
- package/dist/context/platformApi.js.map +1 -0
- package/dist/context/projectInfo.d.ts +30 -0
- package/dist/context/projectInfo.d.ts.map +1 -0
- package/dist/context/projectInfo.js +153 -0
- package/dist/context/projectInfo.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +6 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +159 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +714 -0
- package/dist/index.js.map +1 -0
- package/dist/layer.d.ts +25 -0
- package/dist/layer.d.ts.map +1 -0
- package/dist/layer.js +119 -0
- package/dist/layer.js.map +1 -0
- package/dist/lib/args.d.ts +212 -0
- package/dist/lib/args.d.ts.map +1 -0
- package/dist/lib/args.js +313 -0
- package/dist/lib/args.js.map +1 -0
- package/dist/lib/backupDownload.d.ts +21 -0
- package/dist/lib/backupDownload.d.ts.map +1 -0
- package/dist/lib/backupDownload.js +151 -0
- package/dist/lib/backupDownload.js.map +1 -0
- package/dist/lib/backups.d.ts +12 -0
- package/dist/lib/backups.d.ts.map +1 -0
- package/dist/lib/backups.js +26 -0
- package/dist/lib/backups.js.map +1 -0
- package/dist/lib/config.d.ts +6 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +39 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/createApp.d.ts +12 -0
- package/dist/lib/createApp.d.ts.map +1 -0
- package/dist/lib/createApp.js +15 -0
- package/dist/lib/createApp.js.map +1 -0
- package/dist/lib/email.d.ts +47 -0
- package/dist/lib/email.d.ts.map +1 -0
- package/dist/lib/email.js +71 -0
- package/dist/lib/email.js.map +1 -0
- package/dist/lib/handleEnv.d.ts +7 -0
- package/dist/lib/handleEnv.d.ts.map +1 -0
- package/dist/lib/handleEnv.js +99 -0
- package/dist/lib/handleEnv.js.map +1 -0
- package/dist/lib/http.d.ts +30 -0
- package/dist/lib/http.d.ts.map +1 -0
- package/dist/lib/http.js +55 -0
- package/dist/lib/http.js.map +1 -0
- package/dist/lib/login.d.ts +12 -0
- package/dist/lib/login.d.ts.map +1 -0
- package/dist/lib/login.js +38 -0
- package/dist/lib/login.js.map +1 -0
- package/dist/lib/oauth.d.ts +306 -0
- package/dist/lib/oauth.d.ts.map +1 -0
- package/dist/lib/oauth.js +195 -0
- package/dist/lib/oauth.js.map +1 -0
- package/dist/lib/platformApi.d.ts +5 -0
- package/dist/lib/platformApi.d.ts.map +1 -0
- package/dist/lib/platformApi.js +11 -0
- package/dist/lib/platformApi.js.map +1 -0
- package/dist/lib/pullPerms.d.ts +7 -0
- package/dist/lib/pullPerms.d.ts.map +1 -0
- package/dist/lib/pullPerms.js +41 -0
- package/dist/lib/pullPerms.js.map +1 -0
- package/dist/lib/pullSchema.d.ts +12 -0
- package/dist/lib/pullSchema.d.ts.map +1 -0
- package/dist/lib/pullSchema.js +62 -0
- package/dist/lib/pullSchema.js.map +1 -0
- package/dist/lib/pushPerms.d.ts +13 -0
- package/dist/lib/pushPerms.d.ts.map +1 -0
- package/dist/lib/pushPerms.js +54 -0
- package/dist/lib/pushPerms.js.map +1 -0
- package/dist/lib/pushSchema.d.ts +53 -0
- package/dist/lib/pushSchema.d.ts.map +1 -0
- package/dist/lib/pushSchema.js +165 -0
- package/dist/lib/pushSchema.js.map +1 -0
- package/dist/lib/ui.d.ts +18 -0
- package/dist/lib/ui.d.ts.map +1 -0
- package/dist/lib/ui.js +32 -0
- package/dist/lib/ui.js.map +1 -0
- package/dist/lib/webhooks.d.ts +27 -0
- package/dist/lib/webhooks.d.ts.map +1 -0
- package/dist/lib/webhooks.js +95 -0
- package/dist/lib/webhooks.js.map +1 -0
- package/dist/logging.d.ts +5 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +25 -0
- package/dist/logging.js.map +1 -0
- package/dist/old.d.ts +17 -0
- package/dist/old.d.ts.map +1 -0
- package/dist/old.js +410 -0
- package/dist/old.js.map +1 -0
- package/dist/program.d.ts +3 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +3 -0
- package/dist/program.js.map +1 -0
- package/dist/renderSchemaPlan.d.ts +19 -0
- package/dist/renderSchemaPlan.d.ts.map +1 -0
- package/dist/renderSchemaPlan.js +220 -0
- package/dist/renderSchemaPlan.js.map +1 -0
- package/dist/ui/index.d.ts +292 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +1296 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/lib.d.ts +124 -0
- package/dist/ui/lib.d.ts.map +1 -0
- package/dist/ui/lib.js +333 -0
- package/dist/ui/lib.js.map +1 -0
- package/dist/util/findConfigCandidates.d.ts +13 -0
- package/dist/util/findConfigCandidates.d.ts.map +1 -0
- package/dist/util/findConfigCandidates.js +211 -0
- package/dist/util/findConfigCandidates.js.map +1 -0
- package/dist/util/fs.d.ts +4 -0
- package/dist/util/fs.d.ts.map +1 -0
- package/dist/util/fs.js +22 -0
- package/dist/util/fs.js.map +1 -0
- package/dist/util/getAppName.d.ts +5 -0
- package/dist/util/getAppName.d.ts.map +1 -0
- package/dist/util/getAppName.js +14 -0
- package/dist/util/getAppName.js.map +1 -0
- package/dist/util/instantConfig.d.ts +9 -0
- package/dist/util/instantConfig.d.ts.map +1 -0
- package/dist/util/instantConfig.js +13 -0
- package/dist/util/instantConfig.js.map +1 -0
- package/dist/util/isHeadlessEnvironment.d.ts +4 -0
- package/dist/util/isHeadlessEnvironment.d.ts.map +1 -0
- package/dist/util/isHeadlessEnvironment.js +11 -0
- package/dist/util/isHeadlessEnvironment.js.map +1 -0
- package/dist/util/loadConfig.d.ts +3 -0
- package/dist/util/loadConfig.d.ts.map +1 -0
- package/dist/util/loadConfig.js +72 -0
- package/dist/util/loadConfig.js.map +1 -0
- package/dist/util/loadEnv.d.ts +2 -0
- package/dist/util/loadEnv.d.ts.map +1 -0
- package/dist/util/loadEnv.js +10 -0
- package/dist/util/loadEnv.js.map +1 -0
- package/dist/util/mergeSchema.d.ts +10 -0
- package/dist/util/mergeSchema.d.ts.map +1 -0
- package/dist/util/mergeSchema.js +338 -0
- package/dist/util/mergeSchema.js.map +1 -0
- package/dist/util/projectDir.d.ts +7 -0
- package/dist/util/projectDir.d.ts.map +1 -0
- package/dist/util/projectDir.js +43 -0
- package/dist/util/projectDir.js.map +1 -0
- package/dist/util/renamePrompt.d.ts +15 -0
- package/dist/util/renamePrompt.d.ts.map +1 -0
- package/dist/util/renamePrompt.js +57 -0
- package/dist/util/renamePrompt.js.map +1 -0
- package/dist/util/sdkInstallSpec.d.ts +13 -0
- package/dist/util/sdkInstallSpec.d.ts.map +1 -0
- package/dist/util/sdkInstallSpec.js +37 -0
- package/dist/util/sdkInstallSpec.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/package.json +91 -3
- package/src/auth/index.ts +125 -0
- package/src/commands/app/delete.ts +82 -0
- package/src/commands/app/list.ts +44 -0
- package/src/commands/auth/client/add.ts +744 -0
- package/src/commands/auth/client/delete.ts +60 -0
- package/src/commands/auth/client/list.ts +60 -0
- package/src/commands/auth/client/shared.ts +190 -0
- package/src/commands/auth/client/update.ts +830 -0
- package/src/commands/auth/email/pull.ts +143 -0
- package/src/commands/auth/email/push.ts +94 -0
- package/src/commands/auth/email/resend.ts +8 -0
- package/src/commands/auth/email/reset.ts +37 -0
- package/src/commands/auth/email/status.ts +154 -0
- package/src/commands/auth/email/verify.ts +20 -0
- package/src/commands/auth/origin/add.ts +237 -0
- package/src/commands/auth/origin/delete.ts +50 -0
- package/src/commands/auth/origin/list.ts +66 -0
- package/src/commands/backup/download.ts +231 -0
- package/src/commands/backup/list.ts +94 -0
- package/src/commands/claim.ts +31 -0
- package/src/commands/explorer.ts +21 -0
- package/src/commands/info.ts +57 -0
- package/src/commands/init.ts +60 -0
- package/src/commands/initWithoutFiles.ts +107 -0
- package/src/commands/login.ts +62 -0
- package/src/commands/logout.ts +22 -0
- package/src/commands/pull.ts +22 -0
- package/src/commands/push.ts +25 -0
- package/src/commands/query.ts +61 -0
- package/src/commands/webhooks/add.ts +111 -0
- package/src/commands/webhooks/delete.ts +23 -0
- package/src/commands/webhooks/disable.ts +24 -0
- package/src/commands/webhooks/enable.ts +24 -0
- package/src/commands/webhooks/events/list.ts +38 -0
- package/src/commands/webhooks/events/payload.ts +56 -0
- package/src/commands/webhooks/events/resend.ts +66 -0
- package/src/commands/webhooks/list.ts +41 -0
- package/src/commands/webhooks/shared.ts +339 -0
- package/src/commands/webhooks/update.ts +276 -0
- package/src/context/authToken.ts +134 -0
- package/src/context/currentApp.ts +301 -0
- package/src/context/globalOpts.ts +22 -0
- package/src/context/platformApi.ts +35 -0
- package/src/context/projectInfo.ts +219 -0
- package/src/errors.ts +7 -0
- package/src/index.ts +1212 -0
- package/src/layer.ts +211 -0
- package/src/lib/args.ts +453 -0
- package/src/lib/backupDownload.ts +188 -0
- package/src/lib/backups.ts +33 -0
- package/src/lib/config.ts +73 -0
- package/src/lib/createApp.ts +28 -0
- package/src/lib/email.ts +93 -0
- package/src/lib/handleEnv.ts +122 -0
- package/src/lib/http.ts +128 -0
- package/src/lib/login.ts +48 -0
- package/src/lib/oauth.ts +310 -0
- package/src/lib/platformApi.ts +11 -0
- package/src/lib/pullPerms.ts +50 -0
- package/src/lib/pullSchema.ts +95 -0
- package/src/lib/pushPerms.ts +80 -0
- package/src/lib/pushSchema.ts +248 -0
- package/src/lib/ui.ts +48 -0
- package/src/lib/webhooks.ts +118 -0
- package/src/logging.ts +41 -0
- package/src/old.js +487 -0
- package/src/program.ts +3 -0
- package/src/renderSchemaPlan.ts +324 -0
- package/src/ui/index.ts +1615 -0
- package/src/ui/lib.ts +424 -0
- package/src/util/findConfigCandidates.ts +262 -0
- package/src/util/fs.ts +26 -0
- package/src/util/getAppName.ts +14 -0
- package/src/util/instantConfig.ts +21 -0
- package/src/util/isHeadlessEnvironment.ts +15 -0
- package/src/util/loadConfig.ts +93 -0
- package/src/util/loadEnv.ts +11 -0
- package/src/util/mergeSchema.ts +374 -0
- package/src/util/projectDir.ts +54 -0
- package/src/util/renamePrompt.ts +79 -0
- package/src/util/sdkInstallSpec.ts +45 -0
- package/src/version.js +3 -0
- package/tsconfig.build.json +20 -0
- package/tsconfig.json +23 -0
- package/vitest.config.ts +22 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { test, expect, describe, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { Effect, Layer, Logger } from 'effect';
|
|
3
|
+
import * as NodeContext from '@effect/platform-node/NodeContext';
|
|
4
|
+
import { GlobalOpts } from '../src/context/globalOpts.ts';
|
|
5
|
+
import { CurrentApp } from '../src/context/currentApp.ts';
|
|
6
|
+
import { InstantHttpAuthed } from '../src/lib/http.ts';
|
|
7
|
+
|
|
8
|
+
// -- mocks --
|
|
9
|
+
|
|
10
|
+
// Prevent src/index.ts side-effect (program.parse) from running.
|
|
11
|
+
// add.ts has `import type` from index.ts, but vitest still evaluates it.
|
|
12
|
+
vi.mock('../src/index.ts', () => ({}));
|
|
13
|
+
|
|
14
|
+
let prompts: any[] = [];
|
|
15
|
+
let mockPromptReturn: any = '';
|
|
16
|
+
|
|
17
|
+
vi.mock('../src/ui/lib.ts', async (importOriginal) => {
|
|
18
|
+
const orig: any = await importOriginal();
|
|
19
|
+
return {
|
|
20
|
+
...orig,
|
|
21
|
+
renderUnwrap: (prompt: any) => {
|
|
22
|
+
prompts.push(prompt);
|
|
23
|
+
return Promise.resolve(mockPromptReturn);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
let addedClients: any[] = [];
|
|
29
|
+
|
|
30
|
+
vi.mock('../src/lib/oauth.ts', async () => {
|
|
31
|
+
const { makeOAuthMock } = await import('./oauthMock.ts');
|
|
32
|
+
return makeOAuthMock({
|
|
33
|
+
getAppsAuth: () =>
|
|
34
|
+
Effect.succeed({
|
|
35
|
+
oauth_service_providers: [{ id: 'prov-1', provider_name: 'github' }],
|
|
36
|
+
oauth_clients: [],
|
|
37
|
+
}),
|
|
38
|
+
addOAuthProvider: () =>
|
|
39
|
+
Effect.succeed({
|
|
40
|
+
provider: { id: 'prov-1', provider_name: 'github' },
|
|
41
|
+
}),
|
|
42
|
+
addOAuthClient: (params: any) => {
|
|
43
|
+
addedClients.push(params);
|
|
44
|
+
return Effect.succeed({
|
|
45
|
+
client: {
|
|
46
|
+
id: 'client-1',
|
|
47
|
+
client_name: params.clientName,
|
|
48
|
+
client_id: params.clientId,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Lazy import so mocks are in place
|
|
56
|
+
const { authClientAddCmd } = await import('../src/commands/auth/client/add.ts');
|
|
57
|
+
|
|
58
|
+
// -- helpers --
|
|
59
|
+
|
|
60
|
+
let logs: string[] = [];
|
|
61
|
+
|
|
62
|
+
const run = (flags: Map<string, string>, { yes }: { yes: boolean }) =>
|
|
63
|
+
Effect.runPromise(
|
|
64
|
+
authClientAddCmd(Object.fromEntries(flags) as any).pipe(
|
|
65
|
+
Effect.provide(
|
|
66
|
+
Layer.mergeAll(
|
|
67
|
+
Layer.succeed(GlobalOpts, { yes }),
|
|
68
|
+
Layer.succeed(CurrentApp, { appId: 'test-app', source: 'env' }),
|
|
69
|
+
Layer.succeed(InstantHttpAuthed, {} as any),
|
|
70
|
+
// Provides FileSystem (required by the Apple handler).
|
|
71
|
+
NodeContext.layer,
|
|
72
|
+
Logger.replace(
|
|
73
|
+
Logger.defaultLogger,
|
|
74
|
+
Logger.make(({ message }) => {
|
|
75
|
+
logs.push(String(message));
|
|
76
|
+
}),
|
|
77
|
+
),
|
|
78
|
+
),
|
|
79
|
+
),
|
|
80
|
+
),
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const without = (flags: Map<string, string>, key: string) => {
|
|
84
|
+
const copy = new Map(flags);
|
|
85
|
+
copy.delete(key);
|
|
86
|
+
return copy;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const withEntry = (flags: Map<string, string>, key: string, value: string) =>
|
|
90
|
+
new Map([...flags, [key, value]]);
|
|
91
|
+
|
|
92
|
+
beforeEach(() => {
|
|
93
|
+
vi.stubEnv('INSTANT_CLI_API_URI', undefined);
|
|
94
|
+
prompts = [];
|
|
95
|
+
addedClients = [];
|
|
96
|
+
logs = [];
|
|
97
|
+
mockPromptReturn = '';
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
afterEach(() => {
|
|
101
|
+
vi.unstubAllEnvs();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// -- flag sets --
|
|
105
|
+
|
|
106
|
+
const webFlags = new Map([
|
|
107
|
+
['type', 'github'],
|
|
108
|
+
['name', 'github-web'],
|
|
109
|
+
['client-id', 'Iv1.abc123'],
|
|
110
|
+
['client-secret', 'ghs_abc123'],
|
|
111
|
+
]);
|
|
112
|
+
|
|
113
|
+
// -- --yes: build-up behavior --
|
|
114
|
+
|
|
115
|
+
describe('--yes handles missing values', () => {
|
|
116
|
+
test('missing --type', async () => {
|
|
117
|
+
await run(without(webFlags, 'type'), { yes: true });
|
|
118
|
+
expect(logs.join('\n')).toContain('Missing required value for --type');
|
|
119
|
+
expect(addedClients).toHaveLength(0);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('missing --name uses suggested default', async () => {
|
|
123
|
+
await run(without(webFlags, 'name'), { yes: true });
|
|
124
|
+
expect(prompts).toHaveLength(0);
|
|
125
|
+
expect(addedClients).toHaveLength(1);
|
|
126
|
+
expect(addedClients[0].clientName).toBe('github');
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('missing --client-id', async () => {
|
|
130
|
+
await run(without(webFlags, 'client-id'), { yes: true });
|
|
131
|
+
expect(logs.join('\n')).toContain('Missing required value for --client-id');
|
|
132
|
+
expect(addedClients).toHaveLength(0);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('missing --client-secret', async () => {
|
|
136
|
+
await run(without(webFlags, 'client-secret'), { yes: true });
|
|
137
|
+
expect(logs.join('\n')).toContain(
|
|
138
|
+
'Missing required value for --client-secret',
|
|
139
|
+
);
|
|
140
|
+
expect(addedClients).toHaveLength(0);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// -- interactive prompts for each missing flag --
|
|
145
|
+
|
|
146
|
+
describe('interactive prompts for each missing flag', () => {
|
|
147
|
+
test('missing --type → prompts type selector', async () => {
|
|
148
|
+
mockPromptReturn = 'github';
|
|
149
|
+
await run(without(webFlags, 'type'), { yes: false });
|
|
150
|
+
expect((prompts[0] as any).params.promptText).toBe('Select a client type:');
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test('missing --name → prompts for name', async () => {
|
|
154
|
+
mockPromptReturn = 'github-web';
|
|
155
|
+
await run(without(webFlags, 'name'), { yes: false });
|
|
156
|
+
expect((prompts[0] as any).props.prompt).toBe('Client Name:');
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test('missing --client-id → prompts for client id', async () => {
|
|
160
|
+
mockPromptReturn = 'Iv1.abc123';
|
|
161
|
+
await run(without(webFlags, 'client-id'), { yes: false });
|
|
162
|
+
expect((prompts[0] as any).props.prompt).toContain('Client ID');
|
|
163
|
+
expect((prompts[0] as any).props.prompt).toContain(
|
|
164
|
+
'github.com/settings/developers',
|
|
165
|
+
);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test('missing --client-secret → prompts for client secret', async () => {
|
|
169
|
+
mockPromptReturn = 'ghs_abc123';
|
|
170
|
+
await run(without(webFlags, 'client-secret'), { yes: false });
|
|
171
|
+
expect((prompts[0] as any).props.prompt).toContain('Client Secret:');
|
|
172
|
+
expect((prompts[0] as any).props.sensitive).toBe(true);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test('custom-redirect-uri → prompts when omitted', async () => {
|
|
176
|
+
mockPromptReturn = '';
|
|
177
|
+
await run(webFlags, { yes: false });
|
|
178
|
+
expect(prompts).toHaveLength(1);
|
|
179
|
+
expect((prompts[0] as any).props.placeholder).toBe(
|
|
180
|
+
'https://yoursite.com/oauth/callback',
|
|
181
|
+
);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test('custom-redirect-uri → skipped with --yes', async () => {
|
|
185
|
+
await run(webFlags, { yes: true });
|
|
186
|
+
expect(prompts).toHaveLength(0);
|
|
187
|
+
expect(addedClients).toHaveLength(1);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// -- success cases --
|
|
192
|
+
|
|
193
|
+
describe('success', () => {
|
|
194
|
+
test('uses the configured API URI for the callback URL', async () => {
|
|
195
|
+
vi.stubEnv('INSTANT_CLI_API_URI', 'https://api.instant.example');
|
|
196
|
+
|
|
197
|
+
await run(webFlags, { yes: true });
|
|
198
|
+
|
|
199
|
+
expect(addedClients[0].redirectTo).toBe(
|
|
200
|
+
'https://api.instant.example/runtime/oauth/callback',
|
|
201
|
+
);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test('all required flags → creates client and prints callback URL', async () => {
|
|
205
|
+
await run(webFlags, { yes: true });
|
|
206
|
+
expect(addedClients).toHaveLength(1);
|
|
207
|
+
expect(addedClients[0]).toMatchObject({
|
|
208
|
+
clientName: 'github-web',
|
|
209
|
+
clientId: 'Iv1.abc123',
|
|
210
|
+
clientSecret: 'ghs_abc123',
|
|
211
|
+
redirectTo: 'https://api.instantdb.com/runtime/oauth/callback',
|
|
212
|
+
meta: { providerName: 'github' },
|
|
213
|
+
});
|
|
214
|
+
expect(addedClients[0].authorizationEndpoint).toBeUndefined();
|
|
215
|
+
expect(addedClients[0].tokenEndpoint).toBeUndefined();
|
|
216
|
+
expect(addedClients[0].discoveryEndpoint).toBeUndefined();
|
|
217
|
+
const output = logs.join('\n');
|
|
218
|
+
expect(output).toContain(
|
|
219
|
+
'Add this callback URL in your GitHub OAuth App settings:',
|
|
220
|
+
);
|
|
221
|
+
expect(output).toContain(
|
|
222
|
+
'https://api.instantdb.com/runtime/oauth/callback',
|
|
223
|
+
);
|
|
224
|
+
expect(output).toContain('GitHub OAuth client created: github-web');
|
|
225
|
+
expect(output).toContain('ID: client-1');
|
|
226
|
+
expect(output).toContain('GitHub Client ID: Iv1.abc123');
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test('with custom-redirect-uri → uses it and prints forwarding instructions', async () => {
|
|
230
|
+
await run(
|
|
231
|
+
withEntry(webFlags, 'custom-redirect-uri', 'https://myapp.com/cb'),
|
|
232
|
+
{ yes: true },
|
|
233
|
+
);
|
|
234
|
+
expect(addedClients[0].redirectTo).toBe('https://myapp.com/cb');
|
|
235
|
+
const output = logs.join('\n');
|
|
236
|
+
expect(output).toContain(
|
|
237
|
+
'Add this callback URL in your GitHub OAuth App settings:',
|
|
238
|
+
);
|
|
239
|
+
expect(output).toContain('https://myapp.com/cb');
|
|
240
|
+
expect(output).toContain(
|
|
241
|
+
'https://api.instantdb.com/runtime/oauth/callback with all query parameters',
|
|
242
|
+
);
|
|
243
|
+
expect(output).toContain('https://myapp.com/cb?test-redirect=true');
|
|
244
|
+
});
|
|
245
|
+
});
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { test, expect, describe, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { Effect, Layer, Logger } from 'effect';
|
|
3
|
+
import * as NodeContext from '@effect/platform-node/NodeContext';
|
|
4
|
+
import { GlobalOpts } from '../src/context/globalOpts.ts';
|
|
5
|
+
import { CurrentApp } from '../src/context/currentApp.ts';
|
|
6
|
+
import { InstantHttpAuthed } from '../src/lib/http.ts';
|
|
7
|
+
|
|
8
|
+
// -- mocks --
|
|
9
|
+
|
|
10
|
+
// Prevent src/index.ts side-effect (program.parse) from running.
|
|
11
|
+
// add.ts has `import type` from index.ts, but vitest still evaluates it.
|
|
12
|
+
vi.mock('../src/index.ts', () => ({}));
|
|
13
|
+
|
|
14
|
+
let prompts: any[] = [];
|
|
15
|
+
let mockPromptReturn: any = '';
|
|
16
|
+
|
|
17
|
+
vi.mock('../src/ui/lib.ts', async (importOriginal) => {
|
|
18
|
+
const orig: any = await importOriginal();
|
|
19
|
+
return {
|
|
20
|
+
...orig,
|
|
21
|
+
renderUnwrap: (prompt: any) => {
|
|
22
|
+
prompts.push(prompt);
|
|
23
|
+
return Promise.resolve(mockPromptReturn);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
let addedClients: any[] = [];
|
|
29
|
+
|
|
30
|
+
vi.mock('../src/lib/oauth.ts', async () => {
|
|
31
|
+
const { makeOAuthMock } = await import('./oauthMock.ts');
|
|
32
|
+
return makeOAuthMock({
|
|
33
|
+
getAppsAuth: () =>
|
|
34
|
+
Effect.succeed({
|
|
35
|
+
oauth_service_providers: [{ id: 'prov-1', provider_name: 'google' }],
|
|
36
|
+
oauth_clients: [],
|
|
37
|
+
}),
|
|
38
|
+
addOAuthProvider: () =>
|
|
39
|
+
Effect.succeed({
|
|
40
|
+
provider: { id: 'prov-1', provider_name: 'google' },
|
|
41
|
+
}),
|
|
42
|
+
addOAuthClient: (params: any) => {
|
|
43
|
+
addedClients.push(params);
|
|
44
|
+
return Effect.succeed({
|
|
45
|
+
client: {
|
|
46
|
+
id: 'client-1',
|
|
47
|
+
client_name: params.clientName,
|
|
48
|
+
client_id: params.clientId,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Lazy import so mocks are in place
|
|
56
|
+
const { authClientAddCmd } = await import('../src/commands/auth/client/add.ts');
|
|
57
|
+
|
|
58
|
+
// -- helpers --
|
|
59
|
+
|
|
60
|
+
let logs: string[] = [];
|
|
61
|
+
|
|
62
|
+
const run = (flags: Map<string, string>, { yes }: { yes: boolean }) =>
|
|
63
|
+
Effect.runPromise(
|
|
64
|
+
authClientAddCmd(Object.fromEntries(flags) as any).pipe(
|
|
65
|
+
Effect.provide(
|
|
66
|
+
Layer.mergeAll(
|
|
67
|
+
Layer.succeed(GlobalOpts, { yes }),
|
|
68
|
+
Layer.succeed(CurrentApp, { appId: 'test-app', source: 'env' }),
|
|
69
|
+
Layer.succeed(InstantHttpAuthed, {} as any),
|
|
70
|
+
// Provides FileSystem (required by the Apple handler).
|
|
71
|
+
NodeContext.layer,
|
|
72
|
+
Logger.replace(
|
|
73
|
+
Logger.defaultLogger,
|
|
74
|
+
Logger.make(({ message }) => {
|
|
75
|
+
logs.push(String(message));
|
|
76
|
+
}),
|
|
77
|
+
),
|
|
78
|
+
),
|
|
79
|
+
),
|
|
80
|
+
),
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const without = (flags: Map<string, string>, key: string) => {
|
|
84
|
+
const copy = new Map(flags);
|
|
85
|
+
copy.delete(key);
|
|
86
|
+
return copy;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const withEntry = (flags: Map<string, string>, key: string, value: string) =>
|
|
90
|
+
new Map([...flags, [key, value]]);
|
|
91
|
+
|
|
92
|
+
beforeEach(() => {
|
|
93
|
+
prompts = [];
|
|
94
|
+
addedClients = [];
|
|
95
|
+
logs = [];
|
|
96
|
+
mockPromptReturn = '';
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// -- flag sets --
|
|
100
|
+
|
|
101
|
+
const webFlags = new Map([
|
|
102
|
+
['type', 'google'],
|
|
103
|
+
['app-type', 'web'],
|
|
104
|
+
['name', 'google-web'],
|
|
105
|
+
['client-id', '123456.apps.googleusercontent.com'],
|
|
106
|
+
['client-secret', 'GOCSPX-abc123'],
|
|
107
|
+
]);
|
|
108
|
+
|
|
109
|
+
const iosFlags = new Map([
|
|
110
|
+
['type', 'google'],
|
|
111
|
+
['app-type', 'ios'],
|
|
112
|
+
['name', 'google-ios'],
|
|
113
|
+
['client-id', '123456.apps.googleusercontent.com'],
|
|
114
|
+
]);
|
|
115
|
+
|
|
116
|
+
// -- web: build-up with --yes --
|
|
117
|
+
|
|
118
|
+
describe('web: --yes handles missing values', () => {
|
|
119
|
+
test('missing --type', async () => {
|
|
120
|
+
await run(without(webFlags, 'type'), { yes: true });
|
|
121
|
+
expect(logs.join('\n')).toContain('Missing required value for --type');
|
|
122
|
+
expect(addedClients).toHaveLength(0);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('missing --app-type', async () => {
|
|
126
|
+
await run(without(webFlags, 'app-type'), { yes: true });
|
|
127
|
+
expect(logs.join('\n')).toContain('Missing required value for --app-type');
|
|
128
|
+
expect(addedClients).toHaveLength(0);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('missing --name uses suggested default', async () => {
|
|
132
|
+
await run(without(webFlags, 'name'), { yes: true });
|
|
133
|
+
expect(prompts).toHaveLength(0);
|
|
134
|
+
expect(addedClients).toHaveLength(1);
|
|
135
|
+
expect(addedClients[0].clientName).toBe('google-web');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('missing --client-id', async () => {
|
|
139
|
+
await run(without(webFlags, 'client-id'), { yes: true });
|
|
140
|
+
expect(logs.join('\n')).toContain('Missing required value for --client-id');
|
|
141
|
+
expect(addedClients).toHaveLength(0);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('missing --client-secret', async () => {
|
|
145
|
+
await run(without(webFlags, 'client-secret'), { yes: true });
|
|
146
|
+
expect(logs.join('\n')).toContain(
|
|
147
|
+
'Missing required value for --client-secret',
|
|
148
|
+
);
|
|
149
|
+
expect(addedClients).toHaveLength(0);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// -- web: interactive prompts for each missing flag --
|
|
154
|
+
|
|
155
|
+
describe('web: interactive prompts for each missing flag', () => {
|
|
156
|
+
test('missing --type → prompts type selector', async () => {
|
|
157
|
+
mockPromptReturn = 'google';
|
|
158
|
+
await run(without(webFlags, 'type'), { yes: false });
|
|
159
|
+
expect((prompts[0] as any).params.promptText).toBe('Select a client type:');
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test('missing --app-type → prompts app type selector', async () => {
|
|
163
|
+
mockPromptReturn = 'web';
|
|
164
|
+
await run(without(webFlags, 'app-type'), { yes: false });
|
|
165
|
+
expect((prompts[0] as any).params.promptText).toBe(
|
|
166
|
+
'Select a Google app type:',
|
|
167
|
+
);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test('missing --name → prompts for name', async () => {
|
|
171
|
+
mockPromptReturn = 'google-web';
|
|
172
|
+
await run(without(webFlags, 'name'), { yes: false });
|
|
173
|
+
expect((prompts[0] as any).props.prompt).toBe('Client Name:');
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('missing --client-id → prompts for client id', async () => {
|
|
177
|
+
mockPromptReturn = '123456.apps.googleusercontent.com';
|
|
178
|
+
await run(without(webFlags, 'client-id'), { yes: false });
|
|
179
|
+
expect((prompts[0] as any).props.prompt).toContain('Client ID');
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
test('missing --client-secret → prompts for client secret', async () => {
|
|
183
|
+
mockPromptReturn = 'GOCSPX-abc123';
|
|
184
|
+
await run(without(webFlags, 'client-secret'), { yes: false });
|
|
185
|
+
expect((prompts[0] as any).props.prompt).toContain('Client Secret:');
|
|
186
|
+
expect((prompts[0] as any).props.sensitive).toBe(true);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
test('custom-redirect-uri → prompts when omitted', async () => {
|
|
190
|
+
mockPromptReturn = '';
|
|
191
|
+
await run(webFlags, { yes: false });
|
|
192
|
+
expect(prompts).toHaveLength(1);
|
|
193
|
+
expect((prompts[0] as any).props.placeholder).toBe(
|
|
194
|
+
'https://yoursite.com/oauth/callback',
|
|
195
|
+
);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test('custom-redirect-uri → skipped with --yes', async () => {
|
|
199
|
+
await run(webFlags, { yes: true });
|
|
200
|
+
expect(prompts).toHaveLength(0);
|
|
201
|
+
expect(addedClients).toHaveLength(1);
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// -- web: success cases --
|
|
206
|
+
|
|
207
|
+
describe('web: success', () => {
|
|
208
|
+
test('all required flags → creates client and prints redirect URI', async () => {
|
|
209
|
+
await run(webFlags, { yes: true });
|
|
210
|
+
expect(addedClients).toHaveLength(1);
|
|
211
|
+
expect(addedClients[0]).toMatchObject({
|
|
212
|
+
clientName: 'google-web',
|
|
213
|
+
clientId: '123456.apps.googleusercontent.com',
|
|
214
|
+
clientSecret: 'GOCSPX-abc123',
|
|
215
|
+
});
|
|
216
|
+
const output = logs.join('\n');
|
|
217
|
+
expect(output).toContain('Add this redirect URI in Google Console:');
|
|
218
|
+
expect(output).toContain(
|
|
219
|
+
'https://api.instantdb.com/runtime/oauth/callback',
|
|
220
|
+
);
|
|
221
|
+
expect(output).toContain('Google OAuth client created: google-web');
|
|
222
|
+
expect(output).toContain('App type: web');
|
|
223
|
+
expect(output).toContain('ID: client-1');
|
|
224
|
+
expect(output).toContain(
|
|
225
|
+
'Google Client ID: 123456.apps.googleusercontent.com',
|
|
226
|
+
);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test('with custom-redirect-uri → uses it and prints forwarding instructions', async () => {
|
|
230
|
+
await run(
|
|
231
|
+
withEntry(webFlags, 'custom-redirect-uri', 'https://myapp.com/cb'),
|
|
232
|
+
{ yes: true },
|
|
233
|
+
);
|
|
234
|
+
expect(addedClients[0].redirectTo).toBe('https://myapp.com/cb');
|
|
235
|
+
const output = logs.join('\n');
|
|
236
|
+
expect(output).toContain('Add this redirect URI in Google Console:');
|
|
237
|
+
expect(output).toContain('https://myapp.com/cb');
|
|
238
|
+
expect(output).toContain(
|
|
239
|
+
'https://api.instantdb.com/runtime/oauth/callback with all query parameters',
|
|
240
|
+
);
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
// -- web: dev credentials --
|
|
245
|
+
|
|
246
|
+
const webDevFlags = new Map([
|
|
247
|
+
['type', 'google'],
|
|
248
|
+
['app-type', 'web'],
|
|
249
|
+
['name', 'google-web'],
|
|
250
|
+
]);
|
|
251
|
+
|
|
252
|
+
describe('web: dev credentials', () => {
|
|
253
|
+
test('--dev-credentials → creates dev credentials client', async () => {
|
|
254
|
+
await run(withEntry(webDevFlags, 'dev-credentials', 'true'), { yes: true });
|
|
255
|
+
expect(addedClients).toHaveLength(1);
|
|
256
|
+
expect(addedClients[0]).toMatchObject({
|
|
257
|
+
clientName: 'google-web',
|
|
258
|
+
useSharedCredentials: true,
|
|
259
|
+
discoveryEndpoint:
|
|
260
|
+
'https://accounts.google.com/.well-known/openid-configuration',
|
|
261
|
+
});
|
|
262
|
+
expect(addedClients[0].clientId).toBeUndefined();
|
|
263
|
+
expect(addedClients[0].clientSecret).toBeUndefined();
|
|
264
|
+
expect(addedClients[0].redirectTo).toBeUndefined();
|
|
265
|
+
const output = logs.join('\n');
|
|
266
|
+
expect(output).toContain('Credentials: Instant dev credentials');
|
|
267
|
+
expect(output).toContain('No Google Console setup required');
|
|
268
|
+
expect(output).toContain('Ready for production? Run:');
|
|
269
|
+
expect(output).not.toContain('For production');
|
|
270
|
+
expect(output).toContain(
|
|
271
|
+
'instant-cli auth client update --name google-web',
|
|
272
|
+
);
|
|
273
|
+
expect(output).not.toContain('Add this redirect URI in Google Console');
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
test('--yes with no Google credentials → creates dev credentials client', async () => {
|
|
277
|
+
await run(webDevFlags, { yes: true });
|
|
278
|
+
expect(addedClients).toHaveLength(1);
|
|
279
|
+
expect(addedClients[0]).toMatchObject({
|
|
280
|
+
clientName: 'google-web',
|
|
281
|
+
useSharedCredentials: true,
|
|
282
|
+
discoveryEndpoint:
|
|
283
|
+
'https://accounts.google.com/.well-known/openid-configuration',
|
|
284
|
+
});
|
|
285
|
+
expect(addedClients[0].clientId).toBeUndefined();
|
|
286
|
+
expect(addedClients[0].clientSecret).toBeUndefined();
|
|
287
|
+
expect(addedClients[0].redirectTo).toBeUndefined();
|
|
288
|
+
const output = logs.join('\n');
|
|
289
|
+
expect(output).toContain('Credentials: Instant dev credentials');
|
|
290
|
+
expect(output).toContain('No Google Console setup required');
|
|
291
|
+
expect(output).toContain(
|
|
292
|
+
'instant-cli auth client update --name google-web',
|
|
293
|
+
);
|
|
294
|
+
expect(output).not.toContain('Add this redirect URI in Google Console');
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
test('--dev-credentials with custom credential flags → error', async () => {
|
|
298
|
+
await run(
|
|
299
|
+
new Map([...webDevFlags, ['dev-credentials', 'true'], ['client-id', '']]),
|
|
300
|
+
{ yes: true },
|
|
301
|
+
);
|
|
302
|
+
expect(logs.join('\n')).toContain(
|
|
303
|
+
'--dev-credentials cannot be combined with --client-id',
|
|
304
|
+
);
|
|
305
|
+
expect(addedClients).toHaveLength(0);
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
test('--dev-credentials with native app type → error', async () => {
|
|
309
|
+
await run(
|
|
310
|
+
new Map([
|
|
311
|
+
['type', 'google'],
|
|
312
|
+
['app-type', 'ios'],
|
|
313
|
+
['name', 'google-ios'],
|
|
314
|
+
['dev-credentials', 'true'],
|
|
315
|
+
]),
|
|
316
|
+
{ yes: true },
|
|
317
|
+
);
|
|
318
|
+
expect(logs.join('\n')).toContain(
|
|
319
|
+
'--dev-credentials is only supported for --app-type web',
|
|
320
|
+
);
|
|
321
|
+
expect(addedClients).toHaveLength(0);
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
test('interactive with no Google credentials → prompts for credential mode', async () => {
|
|
325
|
+
mockPromptReturn = 'dev';
|
|
326
|
+
await run(webDevFlags, { yes: false });
|
|
327
|
+
expect(prompts).toHaveLength(1);
|
|
328
|
+
expect((prompts[0] as any).params.promptText).toBe(
|
|
329
|
+
'Select Google credential mode:',
|
|
330
|
+
);
|
|
331
|
+
expect(addedClients).toHaveLength(1);
|
|
332
|
+
expect(addedClients[0].useSharedCredentials).toBe(true);
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
// -- ios: forbidden flags and success --
|
|
337
|
+
|
|
338
|
+
describe('ios', () => {
|
|
339
|
+
test('--client-secret → error (not supported)', async () => {
|
|
340
|
+
await run(withEntry(iosFlags, 'client-secret', 'secret'), { yes: true });
|
|
341
|
+
expect(logs.join('\n')).toContain(
|
|
342
|
+
'--client-secret is not compatible with other options',
|
|
343
|
+
);
|
|
344
|
+
expect(addedClients).toHaveLength(0);
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
test('--custom-redirect-uri → error (not supported)', async () => {
|
|
348
|
+
await run(
|
|
349
|
+
withEntry(iosFlags, 'custom-redirect-uri', 'https://example.com'),
|
|
350
|
+
{ yes: true },
|
|
351
|
+
);
|
|
352
|
+
expect(logs.join('\n')).toContain('not using web app type');
|
|
353
|
+
expect(addedClients).toHaveLength(0);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
test('valid flags → creates client without secret or redirect instructions', async () => {
|
|
357
|
+
await run(iosFlags, { yes: true });
|
|
358
|
+
expect(addedClients).toHaveLength(1);
|
|
359
|
+
expect(addedClients[0]).toMatchObject({
|
|
360
|
+
clientName: 'google-ios',
|
|
361
|
+
clientId: '123456.apps.googleusercontent.com',
|
|
362
|
+
});
|
|
363
|
+
expect(addedClients[0].clientSecret).toBeUndefined();
|
|
364
|
+
const output = logs.join('\n');
|
|
365
|
+
expect(output).not.toContain('Add this redirect URI');
|
|
366
|
+
expect(output).toContain('Google OAuth client created: google-ios');
|
|
367
|
+
expect(output).toContain('App type: ios');
|
|
368
|
+
expect(output).toContain('ID: client-1');
|
|
369
|
+
expect(output).toContain(
|
|
370
|
+
'Google Client ID: 123456.apps.googleusercontent.com',
|
|
371
|
+
);
|
|
372
|
+
});
|
|
373
|
+
});
|