@sidekickdb/cli 0.0.0-stage → 2.0.0
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/NOTICE +27 -0
- package/README.md +68 -2
- package/__tests__/appCommands.test.ts +229 -0
- package/__tests__/args.test.ts +358 -0
- package/__tests__/auth.test.ts +128 -0
- package/__tests__/authClientAddApple.test.ts +377 -0
- package/__tests__/authClientAddClerk.test.ts +223 -0
- package/__tests__/authClientAddGithub.test.ts +245 -0
- package/__tests__/authClientAddGoogle.test.ts +374 -0
- package/__tests__/authClientAddLinkedin.test.ts +263 -0
- package/__tests__/authClientList.test.ts +90 -0
- package/__tests__/authClientUpdate.test.ts +584 -0
- package/__tests__/authOriginManagement.test.ts +308 -0
- package/__tests__/backupDownload.test.ts +206 -0
- package/__tests__/backups.test.ts +222 -0
- package/__tests__/config.test.ts +164 -0
- package/__tests__/configAliases.test.ts +232 -0
- package/__tests__/e2e/cli.e2e.test.ts +1269 -0
- package/__tests__/e2e/helpers.ts +186 -0
- package/__tests__/effectHelpers.ts +45 -0
- package/__tests__/legacyPackageCompat.test.ts +104 -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__/select.test.ts +224 -0
- package/__tests__/webhooks.test.ts +729 -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 +32 -0
- package/dist/context/projectInfo.d.ts.map +1 -0
- package/dist/context/projectInfo.js +160 -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 +721 -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 +13 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +62 -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 +103 -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 +18 -0
- package/dist/old.d.ts.map +1 -0
- package/dist/old.js +423 -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/envAliases.d.ts +25 -0
- package/dist/util/envAliases.d.ts.map +1 -0
- package/dist/util/envAliases.js +47 -0
- package/dist/util/envAliases.js.map +1 -0
- package/dist/util/findConfigCandidates.d.ts +33 -0
- package/dist/util/findConfigCandidates.d.ts.map +1 -0
- package/dist/util/findConfigCandidates.js +230 -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 +80 -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 +16 -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/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 +88 -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 +22 -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 +227 -0
- package/src/errors.ts +7 -0
- package/src/index.ts +1222 -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 +107 -0
- package/src/lib/createApp.ts +28 -0
- package/src/lib/email.ts +93 -0
- package/src/lib/handleEnv.ts +126 -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 +502 -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/envAliases.ts +53 -0
- package/src/util/findConfigCandidates.ts +288 -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 +101 -0
- package/src/util/loadEnv.ts +19 -0
- package/src/util/mergeSchema.ts +374 -0
- package/src/util/projectDir.ts +54 -0
- package/src/util/renamePrompt.ts +79 -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,288 @@
|
|
|
1
|
+
import { existsSync, readdirSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { envNameForDisplay } from './envAliases.ts';
|
|
5
|
+
|
|
6
|
+
type ConfigCandidate = {
|
|
7
|
+
files: string;
|
|
8
|
+
extensions?: string[];
|
|
9
|
+
transform: (code: string) => string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Some framework packages can't be loaded in a Node.js CLI context:
|
|
14
|
+
* - @sidekickdb/react-native brings in react-native which isn't available
|
|
15
|
+
* - @sidekickdb/svelte re-exports .svelte files which can't be parsed
|
|
16
|
+
* - @sidekickdb/vue re-exports .vue files which can't be parsed
|
|
17
|
+
*
|
|
18
|
+
* Since schema files only need schema types (i, id, tx, etc.) which all
|
|
19
|
+
* come from @sidekickdb/core, we rewrite these imports to a safe export
|
|
20
|
+
* in the package that only re-exports from @sidekickdb/core.
|
|
21
|
+
*
|
|
22
|
+
* Legacy @instantdb/* imports are rewritten the same way so existing
|
|
23
|
+
* schema files keep loading.
|
|
24
|
+
*/
|
|
25
|
+
export function transformImports(code: string): string {
|
|
26
|
+
return code
|
|
27
|
+
.replace(
|
|
28
|
+
/["']@(sidekickdb|instantdb)\/react-native["']/g,
|
|
29
|
+
'"@$1/react-native/dist/cli"',
|
|
30
|
+
)
|
|
31
|
+
.replace(
|
|
32
|
+
/["']@(sidekickdb|instantdb)\/svelte["']/g,
|
|
33
|
+
'"@$1/svelte/dist/cli"',
|
|
34
|
+
)
|
|
35
|
+
.replace(/["']@(sidekickdb|instantdb)\/vue["']/g, '"@$1/vue/dist/cli"');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const LEGACY_CONFIG_FILE = /(^|[\\/])instant\.(?=(?:schema|perms|email)$)/;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* `sidekick.schema`, `sidekick.perms` and `sidekick.email` are the SidekickDB
|
|
42
|
+
* names for the `instant.*` files, in the same places. They are listed first,
|
|
43
|
+
* so a `sidekick.*` file wins over an `instant.*` one.
|
|
44
|
+
*/
|
|
45
|
+
export function withSidekickFileNames(
|
|
46
|
+
candidates: ConfigCandidate[],
|
|
47
|
+
): ConfigCandidate[] {
|
|
48
|
+
const renamed = candidates
|
|
49
|
+
.filter((candidate) => LEGACY_CONFIG_FILE.test(candidate.files))
|
|
50
|
+
.map((candidate) => ({
|
|
51
|
+
...candidate,
|
|
52
|
+
files: candidate.files.replace(LEGACY_CONFIG_FILE, '$1sidekick.'),
|
|
53
|
+
}));
|
|
54
|
+
return [...renamed, ...candidates];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function findPathsRecursive(
|
|
58
|
+
baseDir: string,
|
|
59
|
+
maxDepth: number,
|
|
60
|
+
fileName: string,
|
|
61
|
+
): string[] {
|
|
62
|
+
const paths: string[] = [];
|
|
63
|
+
const cwd = process.cwd();
|
|
64
|
+
|
|
65
|
+
const scanDir = (currentDir: string, currentDepth: number): void => {
|
|
66
|
+
if (currentDepth > maxDepth) return;
|
|
67
|
+
|
|
68
|
+
const fullPath = join(cwd, currentDir);
|
|
69
|
+
if (!existsSync(fullPath)) return;
|
|
70
|
+
|
|
71
|
+
paths.push(join(currentDir, fileName));
|
|
72
|
+
|
|
73
|
+
if (currentDepth < maxDepth) {
|
|
74
|
+
try {
|
|
75
|
+
const entries = readdirSync(fullPath, { withFileTypes: true });
|
|
76
|
+
for (const entry of entries) {
|
|
77
|
+
if (
|
|
78
|
+
entry.isDirectory() &&
|
|
79
|
+
!entry.name.startsWith('.') &&
|
|
80
|
+
entry.name !== 'node_modules'
|
|
81
|
+
) {
|
|
82
|
+
scanDir(join(currentDir, entry.name), currentDepth + 1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
} catch (err) {
|
|
86
|
+
console.error(`Error scanning directory ${fullPath}: ${err}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
scanDir(baseDir, 0);
|
|
92
|
+
return paths;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function getEnvSchemaPathWithLogging(): string | undefined {
|
|
96
|
+
const path = process.env.INSTANT_SCHEMA_FILE_PATH;
|
|
97
|
+
if (path) {
|
|
98
|
+
console.log(
|
|
99
|
+
`Using ${envNameForDisplay('INSTANT_SCHEMA_FILE_PATH')}=${chalk.green(process.env.INSTANT_SCHEMA_FILE_PATH)}`,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return path;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function getEnvPermsPathWithLogging(): string | undefined {
|
|
106
|
+
const path = process.env.INSTANT_PERMS_FILE_PATH;
|
|
107
|
+
if (path) {
|
|
108
|
+
console.log(
|
|
109
|
+
`Using ${envNameForDisplay('INSTANT_PERMS_FILE_PATH')}=${chalk.green(process.env.INSTANT_PERMS_FILE_PATH)}`,
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
return path;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function getEnvEmailPathWithLogging(): string | undefined {
|
|
116
|
+
const path = process.env.INSTANT_EMAIL_FILE_PATH;
|
|
117
|
+
if (path) {
|
|
118
|
+
console.log(
|
|
119
|
+
`Using ${envNameForDisplay('INSTANT_EMAIL_FILE_PATH')}=${chalk.green(process.env.INSTANT_EMAIL_FILE_PATH)}`,
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
return path;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function getSchemaReadCandidates(): ConfigCandidate[] {
|
|
126
|
+
const existing = getEnvSchemaPathWithLogging();
|
|
127
|
+
|
|
128
|
+
if (existing) {
|
|
129
|
+
return [{ files: existing, transform: transformImports }];
|
|
130
|
+
}
|
|
131
|
+
const extensions = ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'];
|
|
132
|
+
const candidates: ConfigCandidate[] = [];
|
|
133
|
+
|
|
134
|
+
candidates.push({
|
|
135
|
+
files: 'instant.schema',
|
|
136
|
+
extensions,
|
|
137
|
+
transform: transformImports,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// matches: src/any-folder/any-folder/instant.schema
|
|
141
|
+
// src/any-folder/instant.schema
|
|
142
|
+
// src/instant.schema
|
|
143
|
+
// 3 levels in case someone does src/lib/db/instant.schema
|
|
144
|
+
const srcPaths = findPathsRecursive('src', 3, 'instant.schema');
|
|
145
|
+
for (const srcPath of srcPaths) {
|
|
146
|
+
candidates.push({
|
|
147
|
+
files: srcPath,
|
|
148
|
+
extensions,
|
|
149
|
+
transform: transformImports,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// matches: lib/any-folder/instant.schema
|
|
154
|
+
// lib/instant.schema
|
|
155
|
+
// 2 levels in case someone does lib/db/instant.schema
|
|
156
|
+
const libPaths = findPathsRecursive('lib', 2, 'instant.schema');
|
|
157
|
+
for (const libPath of libPaths) {
|
|
158
|
+
candidates.push({
|
|
159
|
+
files: libPath,
|
|
160
|
+
extensions,
|
|
161
|
+
transform: transformImports,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
candidates.push({
|
|
166
|
+
files: 'app/instant.schema',
|
|
167
|
+
extensions,
|
|
168
|
+
transform: transformImports,
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
return withSidekickFileNames(candidates);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function getPermsReadCandidates(): ConfigCandidate[] {
|
|
175
|
+
const existing = getEnvPermsPathWithLogging();
|
|
176
|
+
if (existing) {
|
|
177
|
+
return [{ files: existing, transform: transformImports }];
|
|
178
|
+
}
|
|
179
|
+
const extensions = ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'];
|
|
180
|
+
|
|
181
|
+
const candidates: ConfigCandidate[] = [];
|
|
182
|
+
|
|
183
|
+
candidates.push({
|
|
184
|
+
files: 'instant.perms',
|
|
185
|
+
extensions,
|
|
186
|
+
transform: transformImports,
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const srcPaths = findPathsRecursive('src', 3, 'instant.perms');
|
|
190
|
+
for (const srcPath of srcPaths) {
|
|
191
|
+
candidates.push({
|
|
192
|
+
files: srcPath,
|
|
193
|
+
extensions,
|
|
194
|
+
transform: transformImports,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const libPaths = findPathsRecursive('lib', 2, 'instant.perms');
|
|
199
|
+
for (const libPath of libPaths) {
|
|
200
|
+
candidates.push({
|
|
201
|
+
files: libPath,
|
|
202
|
+
extensions,
|
|
203
|
+
transform: transformImports,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
candidates.push({
|
|
208
|
+
files: 'app/instant.perms',
|
|
209
|
+
extensions,
|
|
210
|
+
transform: transformImports,
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
return withSidekickFileNames(candidates);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export function getEmailReadCandidates(emailPath?: string): ConfigCandidate[] {
|
|
217
|
+
const existing = emailPath ?? getEnvEmailPathWithLogging();
|
|
218
|
+
if (existing) {
|
|
219
|
+
return [{ files: existing, transform: transformImports }];
|
|
220
|
+
}
|
|
221
|
+
const extensions = ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'];
|
|
222
|
+
|
|
223
|
+
const candidates: ConfigCandidate[] = [];
|
|
224
|
+
|
|
225
|
+
candidates.push({
|
|
226
|
+
files: 'instant.email',
|
|
227
|
+
extensions,
|
|
228
|
+
transform: transformImports,
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
const srcPaths = findPathsRecursive('src', 3, 'instant.email');
|
|
232
|
+
for (const srcPath of srcPaths) {
|
|
233
|
+
candidates.push({
|
|
234
|
+
files: srcPath,
|
|
235
|
+
extensions,
|
|
236
|
+
transform: transformImports,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const libPaths = findPathsRecursive('lib', 2, 'instant.email');
|
|
241
|
+
for (const libPath of libPaths) {
|
|
242
|
+
candidates.push({
|
|
243
|
+
files: libPath,
|
|
244
|
+
extensions,
|
|
245
|
+
transform: transformImports,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
candidates.push({
|
|
250
|
+
files: 'app/instant.email',
|
|
251
|
+
extensions,
|
|
252
|
+
transform: transformImports,
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
return withSidekickFileNames(candidates);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export function getSchemaPathToWrite(existingPath?: string): string {
|
|
259
|
+
if (existingPath) return existingPath;
|
|
260
|
+
if (process.env.INSTANT_SCHEMA_FILE_PATH) {
|
|
261
|
+
return process.env.INSTANT_SCHEMA_FILE_PATH;
|
|
262
|
+
}
|
|
263
|
+
if (existsSync(join(process.cwd(), 'src'))) {
|
|
264
|
+
return join('src', 'instant.schema.ts');
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return 'instant.schema.ts';
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export function getPermsPathToWrite(): string {
|
|
271
|
+
if (process.env.INSTANT_PERMS_FILE_PATH) {
|
|
272
|
+
return process.env.INSTANT_PERMS_FILE_PATH;
|
|
273
|
+
}
|
|
274
|
+
if (existsSync(join(process.cwd(), 'src'))) {
|
|
275
|
+
return join('src', 'instant.perms.ts');
|
|
276
|
+
}
|
|
277
|
+
return 'instant.perms.ts';
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export function getEmailPathToWrite(): string {
|
|
281
|
+
if (process.env.INSTANT_EMAIL_FILE_PATH) {
|
|
282
|
+
return process.env.INSTANT_EMAIL_FILE_PATH;
|
|
283
|
+
}
|
|
284
|
+
if (existsSync(join(process.cwd(), 'src'))) {
|
|
285
|
+
return join('src', 'instant.email.ts');
|
|
286
|
+
}
|
|
287
|
+
return 'instant.email.ts';
|
|
288
|
+
}
|
package/src/util/fs.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { PathLike } from 'fs';
|
|
2
|
+
import { readFile, stat } from 'fs/promises';
|
|
3
|
+
|
|
4
|
+
export async function pathExists(p: PathLike): Promise<boolean> {
|
|
5
|
+
try {
|
|
6
|
+
await stat(p);
|
|
7
|
+
return true;
|
|
8
|
+
} catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function readJsonFile<T = Record<string, any>>(
|
|
14
|
+
p: PathLike,
|
|
15
|
+
): Promise<T | null> {
|
|
16
|
+
if (!pathExists(p)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const data = await readFile(p, 'utf-8');
|
|
22
|
+
return JSON.parse(data);
|
|
23
|
+
} catch (error) {}
|
|
24
|
+
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { InstantHttpAuthed } from '../lib/http.ts';
|
|
3
|
+
import { CurrentApp } from '../context/currentApp.ts';
|
|
4
|
+
import { HttpClientResponse } from '@effect/platform';
|
|
5
|
+
import { DashAppResponse } from '../commands/info.ts';
|
|
6
|
+
|
|
7
|
+
export const getAppName = Effect.gen(function* () {
|
|
8
|
+
const authedHttp = yield* InstantHttpAuthed;
|
|
9
|
+
const { appId } = yield* CurrentApp;
|
|
10
|
+
const appInfo = yield* authedHttp
|
|
11
|
+
.get(`/dash/apps/${appId}`)
|
|
12
|
+
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(DashAppResponse)));
|
|
13
|
+
return appInfo.app.title;
|
|
14
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { loadConfig } from './loadConfig.ts';
|
|
2
|
+
|
|
3
|
+
export type InstantConfig = {
|
|
4
|
+
apiURI?: string;
|
|
5
|
+
dashURI?: string;
|
|
6
|
+
apps?: Record<string, { id: string }>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export async function readInstantConfigFile() {
|
|
10
|
+
return (
|
|
11
|
+
await loadConfig<InstantConfig>({
|
|
12
|
+
// sidekick.config.* is the SidekickDB name for instant.config.*. With
|
|
13
|
+
// `merge: false` the first source that exists is used, so it wins.
|
|
14
|
+
sources: ['sidekick.config', 'instant.config'].map((files) => ({
|
|
15
|
+
files,
|
|
16
|
+
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs', 'json'],
|
|
17
|
+
})),
|
|
18
|
+
merge: false,
|
|
19
|
+
})
|
|
20
|
+
).config;
|
|
21
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function isHeadlessEnvironment(opts?: { headless?: boolean }) {
|
|
2
|
+
const noBrowserMode = Boolean(
|
|
3
|
+
process.env.INSTANT_CLI_NO_BROWSER || process.env.CI || opts?.headless,
|
|
4
|
+
);
|
|
5
|
+
|
|
6
|
+
// Check for common headless environment indicators
|
|
7
|
+
return (
|
|
8
|
+
noBrowserMode ||
|
|
9
|
+
process.env.TERM === 'dumb' ||
|
|
10
|
+
process.env.SSH_CONNECTION !== undefined ||
|
|
11
|
+
process.env.SSH_CLIENT !== undefined ||
|
|
12
|
+
(!process.env.DISPLAY && process.platform === 'linux') ||
|
|
13
|
+
process.env.WSL_DISTRO_NAME !== undefined
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { loadConfig as _loadConfig } from 'unconfig';
|
|
2
|
+
import type {
|
|
3
|
+
LoadConfigOptions,
|
|
4
|
+
LoadConfigResult,
|
|
5
|
+
LoadConfigSource,
|
|
6
|
+
} from 'unconfig';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { findProjectDir } from './projectDir.ts';
|
|
10
|
+
|
|
11
|
+
type Arrayable<T> = T | T[];
|
|
12
|
+
|
|
13
|
+
const toArray = <T>(value: Arrayable<T>): T[] =>
|
|
14
|
+
Array.isArray(value) ? value : [value];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Resolve @sidekickdb packages from the CLI's own dependencies for
|
|
18
|
+
* projects without node_modules. All @sidekickdb packages re-export
|
|
19
|
+
* schema types from core, so a single core alias covers them all.
|
|
20
|
+
* Legacy @instantdb/* names are aliased too so existing schema files
|
|
21
|
+
* keep loading.
|
|
22
|
+
*/
|
|
23
|
+
function getInstantAliases(): Record<string, string> | null {
|
|
24
|
+
try {
|
|
25
|
+
const require = createRequire(import.meta.url);
|
|
26
|
+
const corePackageJson = require.resolve('@sidekickdb/core/package.json');
|
|
27
|
+
const coreDir = path.dirname(corePackageJson);
|
|
28
|
+
return {
|
|
29
|
+
'@sidekickdb/core': coreDir,
|
|
30
|
+
'@sidekickdb/react': coreDir,
|
|
31
|
+
'@sidekickdb/react-native': coreDir,
|
|
32
|
+
'@sidekickdb/svelte': coreDir,
|
|
33
|
+
'@sidekickdb/vue': coreDir,
|
|
34
|
+
'@sidekickdb/admin': coreDir,
|
|
35
|
+
'@instantdb/core': coreDir,
|
|
36
|
+
'@instantdb/react': coreDir,
|
|
37
|
+
'@instantdb/react-native': coreDir,
|
|
38
|
+
'@instantdb/svelte': coreDir,
|
|
39
|
+
'@instantdb/vue': coreDir,
|
|
40
|
+
'@instantdb/admin': coreDir,
|
|
41
|
+
};
|
|
42
|
+
} catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function withAliases<T>(
|
|
48
|
+
opts: LoadConfigOptions<T>,
|
|
49
|
+
alias: Record<string, string>,
|
|
50
|
+
): LoadConfigOptions<T> {
|
|
51
|
+
return {
|
|
52
|
+
...opts,
|
|
53
|
+
sources: toArray(opts.sources).map((source): LoadConfigSource<T> => {
|
|
54
|
+
if (source.parser === 'json' || typeof source.parser === 'function') {
|
|
55
|
+
return source;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
...source,
|
|
60
|
+
parser: async (filepath) => {
|
|
61
|
+
const localRequire = createRequire(import.meta.url);
|
|
62
|
+
const unconfigRequire = createRequire(
|
|
63
|
+
localRequire.resolve('unconfig/package.json'),
|
|
64
|
+
);
|
|
65
|
+
const { createJiti } = unconfigRequire('jiti');
|
|
66
|
+
const jiti = createJiti(import.meta.url, {
|
|
67
|
+
fsCache: false,
|
|
68
|
+
moduleCache: false,
|
|
69
|
+
interopDefault: true,
|
|
70
|
+
alias,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return jiti.import(filepath, { default: true });
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export async function loadConfig<T>(
|
|
81
|
+
opts: LoadConfigOptions<T>,
|
|
82
|
+
): Promise<LoadConfigResult<T>> {
|
|
83
|
+
const projectInfo = await findProjectDir();
|
|
84
|
+
const needsAliases =
|
|
85
|
+
projectInfo?.type === 'deno' || projectInfo?.type === 'python';
|
|
86
|
+
|
|
87
|
+
let res;
|
|
88
|
+
if (needsAliases) {
|
|
89
|
+
const alias = getInstantAliases();
|
|
90
|
+
res = await _loadConfig(alias ? withAliases(opts, alias) : opts);
|
|
91
|
+
} else {
|
|
92
|
+
res = await _loadConfig(opts);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Unconfig seems to add an __esModule property to the config object
|
|
96
|
+
// Removing it.
|
|
97
|
+
if (typeof res.config === 'object' && '__esModule' in res.config!) {
|
|
98
|
+
delete res.config.__esModule;
|
|
99
|
+
}
|
|
100
|
+
return res;
|
|
101
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import dotenvFlow from 'dotenv-flow';
|
|
2
|
+
import { applyEnvAliases } from './envAliases.ts';
|
|
3
|
+
|
|
4
|
+
// index.ts imports this module first, so this runs before any other module is
|
|
5
|
+
// evaluated: some of them read INSTANT_ variables when they load.
|
|
6
|
+
applyEnvAliases();
|
|
7
|
+
|
|
8
|
+
export const loadEnv = () => {
|
|
9
|
+
const envIndex = process.argv.indexOf('--env');
|
|
10
|
+
const envFile = envIndex !== -1 ? process.argv[envIndex + 1] : undefined;
|
|
11
|
+
|
|
12
|
+
dotenvFlow.config({
|
|
13
|
+
silent: true,
|
|
14
|
+
files: envFile ? [envFile] : undefined,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// After the env files: a SIDEKICK_ variable can come from them too.
|
|
18
|
+
applyEnvAliases();
|
|
19
|
+
};
|