@beezer-pet/instant-cli 0.0.0-stage → 1.0.67-beezer.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.
- 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
package/src/layer.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import * as NodeContext from '@effect/platform-node/NodeContext';
|
|
2
|
+
import * as NodeHttpClient from '@effect/platform-node/NodeHttpClient';
|
|
3
|
+
import { Cause, Effect, Layer, ManagedRuntime } from 'effect';
|
|
4
|
+
import { UnknownException } from 'effect/Cause';
|
|
5
|
+
import { inspect } from 'node:util';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import { AuthTokenLive } from './context/authToken.ts';
|
|
8
|
+
import { CurrentAppLive } from './context/currentApp.ts';
|
|
9
|
+
import { GlobalOptsLive } from './context/globalOpts.ts';
|
|
10
|
+
import { PlatformApi, PlatformApiError } from './context/platformApi.ts';
|
|
11
|
+
import {
|
|
12
|
+
PACKAGE_ALIAS_AND_FULL_NAMES,
|
|
13
|
+
ProjectInfoLive,
|
|
14
|
+
} from './context/projectInfo.ts';
|
|
15
|
+
import {
|
|
16
|
+
InstantHttpAuthedLive,
|
|
17
|
+
InstantHttpError,
|
|
18
|
+
InstantHttpLive,
|
|
19
|
+
} from './lib/http.ts';
|
|
20
|
+
import { SimpleLogLayer } from './logging.ts';
|
|
21
|
+
import { RequestError } from '@effect/platform/HttpClientError';
|
|
22
|
+
|
|
23
|
+
const runtime = ManagedRuntime.make(SimpleLogLayer);
|
|
24
|
+
|
|
25
|
+
// Best-effort stringification for unknown error causes. Tries JSON first
|
|
26
|
+
// (compact, readable) and falls back to util.inspect for circular refs or
|
|
27
|
+
// values JSON can't serialize (functions, BigInt, etc.).
|
|
28
|
+
function serializeCause(cause: unknown): string {
|
|
29
|
+
try {
|
|
30
|
+
const json = JSON.stringify(cause);
|
|
31
|
+
if (json !== undefined) return json;
|
|
32
|
+
} catch {
|
|
33
|
+
// fall through
|
|
34
|
+
}
|
|
35
|
+
return inspect(cause, { depth: 2, breakLength: Infinity });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const runCommandEffect = <A, E, R extends never>(
|
|
39
|
+
effect: Effect.Effect<A, E, R>,
|
|
40
|
+
): Promise<A> => runtime.runPromise(effect.pipe(printRedErrors) as any);
|
|
41
|
+
|
|
42
|
+
export const printRedErrors = Effect.catchAllCause((cause) =>
|
|
43
|
+
Effect.gen(function* () {
|
|
44
|
+
const failure = Cause.failureOption(cause);
|
|
45
|
+
|
|
46
|
+
// This should never happen because the catchAllCause should only fire when there IS a failure
|
|
47
|
+
if (failure._tag !== 'Some') {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Unwrap Effect.tryPromise's UnknownException so instanceof checks below
|
|
52
|
+
// match regardless of whether the error was Effect.fail'd or thrown from a Promise.
|
|
53
|
+
const theError =
|
|
54
|
+
failure.value instanceof UnknownException
|
|
55
|
+
? failure.value.error
|
|
56
|
+
: failure.value;
|
|
57
|
+
|
|
58
|
+
// Simplify "can't connect to url errors" instead of printing
|
|
59
|
+
// crazy stack trace
|
|
60
|
+
if (theError instanceof RequestError) {
|
|
61
|
+
yield* Effect.logError(theError.toString());
|
|
62
|
+
return process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Surface server-side validation messages instead of dumping a stack with
|
|
66
|
+
// the useful detail buried in [cause].
|
|
67
|
+
if (theError instanceof PlatformApiError) {
|
|
68
|
+
const cause = theError.cause;
|
|
69
|
+
const causeMessage =
|
|
70
|
+
cause instanceof Error
|
|
71
|
+
? cause.message
|
|
72
|
+
: cause != null
|
|
73
|
+
? serializeCause(cause)
|
|
74
|
+
: '';
|
|
75
|
+
yield* Effect.logError(
|
|
76
|
+
causeMessage
|
|
77
|
+
? `${theError.message}: ${causeMessage}`
|
|
78
|
+
: theError.message,
|
|
79
|
+
);
|
|
80
|
+
return process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Special error handling for specific error types
|
|
84
|
+
if (theError instanceof InstantHttpError) {
|
|
85
|
+
if (theError?.message) {
|
|
86
|
+
yield* Effect.logError(
|
|
87
|
+
'Error making request to Instant API: ' + theError.message,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
if (Array.isArray(theError?.hint?.errors)) {
|
|
91
|
+
for (const err of theError.hint.errors) {
|
|
92
|
+
if (err) {
|
|
93
|
+
if (typeof err === 'string') {
|
|
94
|
+
yield* Effect.logError(err);
|
|
95
|
+
} else {
|
|
96
|
+
yield* Effect.logError(
|
|
97
|
+
`${err.in ? err.in.join('->') + ': ' : ''}${err.message}`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Print just the message if the error has a message attribute and no cause
|
|
107
|
+
if (
|
|
108
|
+
typeof theError === 'object' &&
|
|
109
|
+
theError !== null &&
|
|
110
|
+
'message' in theError &&
|
|
111
|
+
typeof theError.message === 'string' &&
|
|
112
|
+
!('cause' in theError)
|
|
113
|
+
) {
|
|
114
|
+
return yield* Effect.logError(theError.message).pipe(
|
|
115
|
+
Effect.tap(() => {
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}),
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return yield* Effect.logError(
|
|
122
|
+
Cause.pretty(cause, { renderErrorCause: true }),
|
|
123
|
+
).pipe(
|
|
124
|
+
Effect.tap(() => {
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}),
|
|
127
|
+
);
|
|
128
|
+
}),
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Note:
|
|
133
|
+
Avoid Duplicate Layer Creation
|
|
134
|
+
|
|
135
|
+
Layers are memoized using reference equality. Therefore, if you have a layer that is created by calling a function like f(), you should only call that f once and re-use the resulting layer so that you are always using the same instance.
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
// TODO: make coerce param work for auth too
|
|
139
|
+
|
|
140
|
+
// Base layers
|
|
141
|
+
const AuthTokenLayer = ({
|
|
142
|
+
allowAdminToken = true,
|
|
143
|
+
coerce = false,
|
|
144
|
+
}: {
|
|
145
|
+
allowAdminToken: boolean;
|
|
146
|
+
coerce: boolean;
|
|
147
|
+
}) =>
|
|
148
|
+
Layer.provide(AuthTokenLive({ allowAdminToken, coerce }), NodeContext.layer);
|
|
149
|
+
|
|
150
|
+
const InstantHttpLayer = Layer.provide(InstantHttpLive, NodeHttpClient.layer);
|
|
151
|
+
|
|
152
|
+
// Unauthenticated layer with InstantHttp + PlatformApi + GlobalOpts + NodeContext
|
|
153
|
+
export const BaseLayerLive = Layer.provideMerge(
|
|
154
|
+
Layer.mergeAll(InstantHttpLayer, PlatformApi.Default, GlobalOptsLive),
|
|
155
|
+
NodeContext.layer,
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
// Authenticated layer extends BaseLayerLive with InstantHttpAuthed
|
|
159
|
+
export const AuthLayerLive = ({
|
|
160
|
+
allowAdminToken = true,
|
|
161
|
+
coerce = false,
|
|
162
|
+
}: {
|
|
163
|
+
allowAdminToken: boolean;
|
|
164
|
+
coerce: boolean;
|
|
165
|
+
}) =>
|
|
166
|
+
Layer.provideMerge(
|
|
167
|
+
Layer.provideMerge(
|
|
168
|
+
InstantHttpAuthedLive,
|
|
169
|
+
Layer.merge(
|
|
170
|
+
AuthTokenLayer({ allowAdminToken, coerce }),
|
|
171
|
+
InstantHttpLayer,
|
|
172
|
+
),
|
|
173
|
+
),
|
|
174
|
+
BaseLayerLive,
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
export const WithAppLayer = (args: {
|
|
178
|
+
appId?: string;
|
|
179
|
+
title?: string;
|
|
180
|
+
coerce: boolean;
|
|
181
|
+
coerceAuth?: boolean;
|
|
182
|
+
coerceLibraryInstall?: boolean;
|
|
183
|
+
packageName?: keyof typeof PACKAGE_ALIAS_AND_FULL_NAMES;
|
|
184
|
+
allowAdminToken?: boolean;
|
|
185
|
+
applyEnv?: boolean;
|
|
186
|
+
temp?: boolean;
|
|
187
|
+
}) =>
|
|
188
|
+
Layer.mergeAll(
|
|
189
|
+
CurrentAppLive({
|
|
190
|
+
coerce: args.coerce,
|
|
191
|
+
appId: args.appId,
|
|
192
|
+
title: args.title,
|
|
193
|
+
applyEnv: args.applyEnv,
|
|
194
|
+
temp: args.temp,
|
|
195
|
+
}),
|
|
196
|
+
).pipe(
|
|
197
|
+
Layer.provideMerge(
|
|
198
|
+
AuthLayerLive({
|
|
199
|
+
allowAdminToken:
|
|
200
|
+
args.allowAdminToken !== undefined ? args.allowAdminToken : true,
|
|
201
|
+
coerce: args.coerceAuth ?? false,
|
|
202
|
+
}),
|
|
203
|
+
),
|
|
204
|
+
Layer.provideMerge(
|
|
205
|
+
ProjectInfoLive(
|
|
206
|
+
args.coerceLibraryInstall ?? args.coerce,
|
|
207
|
+
args.packageName,
|
|
208
|
+
),
|
|
209
|
+
),
|
|
210
|
+
Layer.provideMerge(BaseLayerLive),
|
|
211
|
+
);
|
package/src/lib/args.ts
ADDED
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Args lets commands read CLI flags as a small pipeline:
|
|
3
|
+
*
|
|
4
|
+
* 1. Parse a value from opts
|
|
5
|
+
* 2. Gate it: when is this flag available?
|
|
6
|
+
* 3. Prompt for a missing value, when interactive
|
|
7
|
+
* 4. Validate and finish as required or optional
|
|
8
|
+
*
|
|
9
|
+
* This keeps the "can this flag be used here?" logic next to the value it
|
|
10
|
+
* controls. For example, a Google client secret is only meaningful when using
|
|
11
|
+
* custom web credentials:
|
|
12
|
+
*
|
|
13
|
+
* const clientSecret = yield* Args.text(opts, 'client-secret').pipe(
|
|
14
|
+
* Args.availableWhen(usesCustomWebCredentials),
|
|
15
|
+
* Args.prompt(clientSecretPrompt({ providerUrl })),
|
|
16
|
+
* Args.required(),
|
|
17
|
+
* );
|
|
18
|
+
*
|
|
19
|
+
* The key argument to text/bool/has is the exact opts lookup key. If the
|
|
20
|
+
* user-facing flag name differs, pass simpleName for errors:
|
|
21
|
+
*
|
|
22
|
+
* Args.text(opts, 'customRedirectUri', { simpleName: '--custom-redirect-uri' })
|
|
23
|
+
*/
|
|
24
|
+
import { Effect } from 'effect';
|
|
25
|
+
import { pipeArguments, type Pipeable } from 'effect/Pipeable';
|
|
26
|
+
import { BadArgsError } from '../errors.ts';
|
|
27
|
+
import { GlobalOpts } from '../context/globalOpts.ts';
|
|
28
|
+
import { UI } from '../ui/index.ts';
|
|
29
|
+
import { runUIEffect } from './ui.ts';
|
|
30
|
+
|
|
31
|
+
type ActiveArg<A, E, R> = {
|
|
32
|
+
readonly _tag: 'Active';
|
|
33
|
+
readonly provided: boolean;
|
|
34
|
+
readonly value: Effect.Effect<A | undefined, E, R>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type InactiveArg = {
|
|
38
|
+
readonly _tag: 'Inactive';
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type ArgState<A, E, R, CanBeInactive extends boolean> =
|
|
42
|
+
| ActiveArg<A, E, R>
|
|
43
|
+
| (CanBeInactive extends true ? InactiveArg : never);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A parsed CLI arg that can be composed with Args helpers.
|
|
47
|
+
*
|
|
48
|
+
* Commands usually create one with text() or bool(), then finish with
|
|
49
|
+
* required() or optional().
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* const name = yield* Args.text(opts, 'name').pipe(
|
|
53
|
+
* Args.prompt({ prompt: 'Client Name:' }),
|
|
54
|
+
* Args.required(),
|
|
55
|
+
* );
|
|
56
|
+
*/
|
|
57
|
+
export interface Arg<
|
|
58
|
+
A,
|
|
59
|
+
E = never,
|
|
60
|
+
R = never,
|
|
61
|
+
CanBeInactive extends boolean = false,
|
|
62
|
+
> extends Pipeable {
|
|
63
|
+
readonly flag: string;
|
|
64
|
+
readonly state: Effect.Effect<ArgState<A, E, R, CanBeInactive>, E, R>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type ArgOptions = {
|
|
68
|
+
/**
|
|
69
|
+
* Use when the opts key is not the user-facing flag name.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* Args.text(opts, 'customRedirectUri', {
|
|
73
|
+
* simpleName: '--custom-redirect-uri',
|
|
74
|
+
* })
|
|
75
|
+
*/
|
|
76
|
+
simpleName?: string;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const makeArg = <A, E, R, CanBeInactive extends boolean>(
|
|
80
|
+
flag: string,
|
|
81
|
+
state: Effect.Effect<ArgState<A, E, R, CanBeInactive>, E, R>,
|
|
82
|
+
): Arg<A, E, R, CanBeInactive> => {
|
|
83
|
+
const arg: Arg<A, E, R, CanBeInactive> = {
|
|
84
|
+
flag,
|
|
85
|
+
state,
|
|
86
|
+
pipe() {
|
|
87
|
+
return pipeArguments(this, arguments);
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
return arg;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const active = <A, E, R>(
|
|
94
|
+
value: Effect.Effect<A | undefined, E, R>,
|
|
95
|
+
provided: boolean,
|
|
96
|
+
): ActiveArg<A, E, R> => ({ _tag: 'Active', provided, value });
|
|
97
|
+
|
|
98
|
+
const inactive: InactiveArg = { _tag: 'Inactive' };
|
|
99
|
+
|
|
100
|
+
const missingMessage = (flag: string) => `Missing required value for ${flag}`;
|
|
101
|
+
|
|
102
|
+
type MissingOptions = {
|
|
103
|
+
message?: string;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
type UnavailableOptions = {
|
|
107
|
+
message?: string;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @example
|
|
112
|
+
* if (Args.has(opts, 'custom-redirect-uri')) {
|
|
113
|
+
* // The user explicitly passed --custom-redirect-uri.
|
|
114
|
+
* }
|
|
115
|
+
*/
|
|
116
|
+
function has(opts: Record<string, unknown>, key: string) {
|
|
117
|
+
return Object.prototype.hasOwnProperty.call(opts, key);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @example
|
|
122
|
+
* const configureWeb = Args.hasAny(opts, [
|
|
123
|
+
* 'team-id',
|
|
124
|
+
* 'key-id',
|
|
125
|
+
* 'private-key-file',
|
|
126
|
+
* ]);
|
|
127
|
+
*/
|
|
128
|
+
function hasAny(opts: Record<string, unknown>, keys: string[]) {
|
|
129
|
+
return keys.some((key) => has(opts, key));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Returns true only for boolean true or the string "true".
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* const useDevCredentials = Args.isTrue(opts, 'dev-credentials');
|
|
137
|
+
*/
|
|
138
|
+
function isTrue(opts: Record<string, unknown>, key: string) {
|
|
139
|
+
const value = opts[key];
|
|
140
|
+
return value === true || value === 'true';
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Starts a string arg pipeline. Strings are trimmed, numbers are stringified,
|
|
145
|
+
* empty values become missing values, and other types produce BadArgsError.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* const clientId = yield* Args.text(opts, 'client-id').pipe(
|
|
149
|
+
* Args.prompt(clientIdPrompt({ providerUrl })),
|
|
150
|
+
* Args.required(),
|
|
151
|
+
* );
|
|
152
|
+
*/
|
|
153
|
+
function text(
|
|
154
|
+
opts: Record<string, unknown>,
|
|
155
|
+
key: string,
|
|
156
|
+
options?: ArgOptions,
|
|
157
|
+
): Arg<string, BadArgsError> {
|
|
158
|
+
const flag = options?.simpleName ?? `--${key}`;
|
|
159
|
+
const provided = Object.prototype.hasOwnProperty.call(opts, key);
|
|
160
|
+
|
|
161
|
+
return makeArg(
|
|
162
|
+
flag,
|
|
163
|
+
Effect.succeed(active(readTextValue(opts[key], flag), provided)),
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function readTextValue(value: unknown, flag: string) {
|
|
168
|
+
return Effect.gen(function* readTextValue() {
|
|
169
|
+
if (value === undefined || value === null) return undefined;
|
|
170
|
+
|
|
171
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
172
|
+
const trimmed = String(value).trim();
|
|
173
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return yield* BadArgsError.make({
|
|
177
|
+
message: `Invalid value for ${flag}`,
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Starts a boolean arg pipeline. Accepts booleans and the strings "true" or
|
|
184
|
+
* "false"; other supplied values produce BadArgsError.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* const configureWeb = yield* Args.bool(opts, 'configure-web').pipe(
|
|
188
|
+
* Args.confirm({ promptText: 'Configure web redirect flow?' }),
|
|
189
|
+
* Args.required(),
|
|
190
|
+
* );
|
|
191
|
+
*/
|
|
192
|
+
function bool(
|
|
193
|
+
opts: Record<string, unknown>,
|
|
194
|
+
key: string,
|
|
195
|
+
options?: ArgOptions,
|
|
196
|
+
): Arg<boolean, BadArgsError> {
|
|
197
|
+
const flag = options?.simpleName ?? `--${key}`;
|
|
198
|
+
const provided = Object.prototype.hasOwnProperty.call(opts, key);
|
|
199
|
+
|
|
200
|
+
return makeArg(
|
|
201
|
+
flag,
|
|
202
|
+
Effect.succeed(active(readBooleanValue(opts[key], flag), provided)),
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function readBooleanValue(value: unknown, flag: string) {
|
|
207
|
+
return Effect.gen(function* readBooleanValue() {
|
|
208
|
+
if (value === undefined || value === null) return undefined;
|
|
209
|
+
if (value === true || value === 'true') return true;
|
|
210
|
+
if (value === false || value === 'false') return false;
|
|
211
|
+
|
|
212
|
+
return yield* BadArgsError.make({
|
|
213
|
+
message: `Invalid value for ${flag}`,
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function uiErrorToBadArgs(e: { message: string }) {
|
|
219
|
+
return BadArgsError.make({ message: `UI error: ${e.message}` });
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function mapActive<A, B, E, R, E2, R2, CanBeInactive extends boolean>(
|
|
223
|
+
wrapper: Arg<A, E, R, CanBeInactive>,
|
|
224
|
+
mapValue: (
|
|
225
|
+
value: Effect.Effect<A | undefined, E, R>,
|
|
226
|
+
) => Effect.Effect<B | undefined, E | E2, R | R2>,
|
|
227
|
+
): Arg<B, E | E2, R | R2, CanBeInactive> {
|
|
228
|
+
return makeArg(
|
|
229
|
+
wrapper.flag,
|
|
230
|
+
Effect.gen(function* mapArgState() {
|
|
231
|
+
const state = yield* wrapper.state;
|
|
232
|
+
if (state._tag === 'Inactive') return inactive;
|
|
233
|
+
return active(mapValue(state.value), state.provided);
|
|
234
|
+
}) as Effect.Effect<
|
|
235
|
+
ArgState<B, E | E2, R | R2, CanBeInactive>,
|
|
236
|
+
E | E2,
|
|
237
|
+
R | R2
|
|
238
|
+
>,
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Gates an arg behind a mode or earlier choice.
|
|
244
|
+
*
|
|
245
|
+
* If the condition is false and the user supplied the flag, this returns an
|
|
246
|
+
* error.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* const clientSecret = yield* Args.text(opts, 'client-secret').pipe(
|
|
250
|
+
* Args.availableWhen(appType === 'web'),
|
|
251
|
+
* Args.prompt(clientSecretPrompt({ providerUrl })),
|
|
252
|
+
* Args.required(),
|
|
253
|
+
* );
|
|
254
|
+
*/
|
|
255
|
+
function availableWhen(condition: boolean, options?: UnavailableOptions) {
|
|
256
|
+
return function availableWhenArg<A, E, R, CanBeInactive extends boolean>(
|
|
257
|
+
arg: Arg<A, E, R, CanBeInactive>,
|
|
258
|
+
) {
|
|
259
|
+
return makeArg<A, E | BadArgsError, R, true>(
|
|
260
|
+
arg.flag,
|
|
261
|
+
Effect.gen(function* gateArgAvailability() {
|
|
262
|
+
const state = yield* arg.state;
|
|
263
|
+
if (condition || state._tag === 'Inactive') return state;
|
|
264
|
+
if (state.provided) {
|
|
265
|
+
return yield* BadArgsError.make({
|
|
266
|
+
message:
|
|
267
|
+
options?.message ??
|
|
268
|
+
`${arg.flag} is not compatible with other options`,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
return inactive;
|
|
272
|
+
}),
|
|
273
|
+
);
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Prompts for a missing text value.
|
|
279
|
+
*
|
|
280
|
+
* With --yes, the prompt is skipped. If inputProps.defaultValue is set, that
|
|
281
|
+
* value is used. Otherwise the value stays missing.
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* const clientName = yield* Args.text(opts, 'name').pipe(
|
|
285
|
+
* Args.prompt({
|
|
286
|
+
* prompt: 'Client Name:',
|
|
287
|
+
* defaultValue: suggestedClientName,
|
|
288
|
+
* }),
|
|
289
|
+
* Args.required(),
|
|
290
|
+
* );
|
|
291
|
+
*/
|
|
292
|
+
function prompt(inputProps: UI.TextInputProps) {
|
|
293
|
+
return function promptArg<E, R, CanBeInactive extends boolean>(
|
|
294
|
+
arg: Arg<string, E, R, CanBeInactive>,
|
|
295
|
+
): Arg<string, E | BadArgsError, R | GlobalOpts, CanBeInactive> {
|
|
296
|
+
return mapActive(arg, (valueEffect) =>
|
|
297
|
+
Effect.gen(function* promptWhenMissing() {
|
|
298
|
+
const value = yield* valueEffect;
|
|
299
|
+
if (value !== undefined) return value;
|
|
300
|
+
|
|
301
|
+
const { yes } = yield* GlobalOpts;
|
|
302
|
+
const result = yes
|
|
303
|
+
? inputProps.defaultValue
|
|
304
|
+
: yield* runUIEffect(new UI.TextInput(inputProps)).pipe(
|
|
305
|
+
Effect.catchTag('UIError', uiErrorToBadArgs),
|
|
306
|
+
);
|
|
307
|
+
if (result === undefined) return undefined;
|
|
308
|
+
|
|
309
|
+
const trimmed = result.trim();
|
|
310
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
311
|
+
}),
|
|
312
|
+
);
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Prompts for a missing boolean value.
|
|
318
|
+
*
|
|
319
|
+
* With --yes, the prompt is skipped and confirmationProps.defaultValue is used.
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* const configureWeb = yield* Args.bool(opts, 'configure-web').pipe(
|
|
323
|
+
* Args.confirm({
|
|
324
|
+
* promptText: 'Configure web redirect flow?',
|
|
325
|
+
* defaultValue: false,
|
|
326
|
+
* }),
|
|
327
|
+
* Args.required(),
|
|
328
|
+
* );
|
|
329
|
+
*/
|
|
330
|
+
function confirm(confirmationProps: UI.ConfirmationProps) {
|
|
331
|
+
return function confirmArg<E, R, CanBeInactive extends boolean>(
|
|
332
|
+
arg: Arg<boolean, E, R, CanBeInactive>,
|
|
333
|
+
): Arg<boolean, E | BadArgsError, R | GlobalOpts, CanBeInactive> {
|
|
334
|
+
return mapActive(arg, (valueEffect) =>
|
|
335
|
+
Effect.gen(function* confirmWhenMissing() {
|
|
336
|
+
const value = yield* valueEffect;
|
|
337
|
+
if (value !== undefined) return value;
|
|
338
|
+
|
|
339
|
+
const { yes } = yield* GlobalOpts;
|
|
340
|
+
if (yes) return confirmationProps.defaultValue;
|
|
341
|
+
|
|
342
|
+
return yield* runUIEffect(new UI.Confirmation(confirmationProps)).pipe(
|
|
343
|
+
Effect.catchTag('UIError', uiErrorToBadArgs),
|
|
344
|
+
);
|
|
345
|
+
}),
|
|
346
|
+
);
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Validates a present value. Return an error message to fail, or undefined to
|
|
352
|
+
* accept the value. Missing and inactive args pass through unchanged.
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* const projectId = yield* Args.text(opts, 'project-id').pipe(
|
|
356
|
+
* Args.prompt(firebaseProjectIdPrompt({})),
|
|
357
|
+
* Args.validate(validateFirebaseProjectId),
|
|
358
|
+
* Args.required(),
|
|
359
|
+
* );
|
|
360
|
+
*/
|
|
361
|
+
function validate<A>(validator: (value: A) => string | undefined) {
|
|
362
|
+
return function validateArg<E, R, CanBeInactive extends boolean>(
|
|
363
|
+
arg: Arg<A, E, R, CanBeInactive>,
|
|
364
|
+
): Arg<A, E | BadArgsError, R, CanBeInactive> {
|
|
365
|
+
return mapActive(arg, (valueEffect) =>
|
|
366
|
+
Effect.gen(function* validateValue() {
|
|
367
|
+
const value = yield* valueEffect;
|
|
368
|
+
if (value === undefined) return undefined;
|
|
369
|
+
|
|
370
|
+
const message = validator(value);
|
|
371
|
+
if (!message) return value;
|
|
372
|
+
|
|
373
|
+
return yield* BadArgsError.make({ message });
|
|
374
|
+
}),
|
|
375
|
+
);
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Finishes a pipeline with a required value.
|
|
381
|
+
*
|
|
382
|
+
* Missing active args produce BadArgsError. Inactive args return undefined, so
|
|
383
|
+
* callers can skip downstream work for unavailable flags.
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* const clientId = yield* Args.text(opts, 'client-id').pipe(
|
|
387
|
+
* Args.prompt(clientIdPrompt({ providerUrl })),
|
|
388
|
+
* Args.required(),
|
|
389
|
+
* );
|
|
390
|
+
*/
|
|
391
|
+
function required(options?: MissingOptions) {
|
|
392
|
+
return function requiredArg<A, E, R, CanBeInactive extends boolean>(
|
|
393
|
+
arg: Arg<A, E, R, CanBeInactive>,
|
|
394
|
+
): Effect.Effect<
|
|
395
|
+
CanBeInactive extends true ? A | undefined : A,
|
|
396
|
+
E | BadArgsError,
|
|
397
|
+
R
|
|
398
|
+
> {
|
|
399
|
+
return Effect.gen(function* requireValue() {
|
|
400
|
+
const state = yield* arg.state;
|
|
401
|
+
if (state._tag === 'Inactive') return undefined;
|
|
402
|
+
|
|
403
|
+
const value = yield* state.value;
|
|
404
|
+
if (value !== undefined) return value;
|
|
405
|
+
|
|
406
|
+
return yield* BadArgsError.make({
|
|
407
|
+
message: options?.message ?? missingMessage(arg.flag),
|
|
408
|
+
});
|
|
409
|
+
}) as Effect.Effect<
|
|
410
|
+
CanBeInactive extends true ? A | undefined : A,
|
|
411
|
+
E | BadArgsError,
|
|
412
|
+
R
|
|
413
|
+
>;
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Finishes a pipeline with an optional value.
|
|
419
|
+
*
|
|
420
|
+
* Missing and inactive args return undefined.
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* const customRedirectUri = yield* Args.text(opts, 'custom-redirect-uri').pipe(
|
|
424
|
+
* Args.prompt(optionalRedirectPrompt),
|
|
425
|
+
* Args.optional(),
|
|
426
|
+
* );
|
|
427
|
+
*/
|
|
428
|
+
function optional() {
|
|
429
|
+
return function optionalArg<A, E, R, CanBeInactive extends boolean>(
|
|
430
|
+
arg: Arg<A, E, R, CanBeInactive>,
|
|
431
|
+
) {
|
|
432
|
+
return Effect.gen(function* optionalValue() {
|
|
433
|
+
const state = yield* arg.state;
|
|
434
|
+
if (state._tag === 'Inactive') return undefined;
|
|
435
|
+
|
|
436
|
+
return yield* state.value;
|
|
437
|
+
});
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
export const Args = {
|
|
442
|
+
text,
|
|
443
|
+
bool,
|
|
444
|
+
has,
|
|
445
|
+
hasAny,
|
|
446
|
+
isTrue,
|
|
447
|
+
availableWhen,
|
|
448
|
+
prompt,
|
|
449
|
+
confirm,
|
|
450
|
+
validate,
|
|
451
|
+
required,
|
|
452
|
+
optional,
|
|
453
|
+
};
|