@sidekickdb/cli 2.0.0 → 3.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.
Files changed (265) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/README.md +5 -5
  3. package/__tests__/appCommands.test.ts +8 -8
  4. package/__tests__/auth.test.ts +11 -65
  5. package/__tests__/authClientAddApple.test.ts +3 -3
  6. package/__tests__/authClientAddClerk.test.ts +8 -13
  7. package/__tests__/authClientAddGithub.test.ts +5 -5
  8. package/__tests__/authClientAddGoogle.test.ts +3 -3
  9. package/__tests__/authClientAddLinkedin.test.ts +3 -3
  10. package/__tests__/authClientList.test.ts +4 -3
  11. package/__tests__/authClientUpdate.test.ts +6 -8
  12. package/__tests__/authOriginManagement.test.ts +11 -11
  13. package/__tests__/backups.test.ts +2 -2
  14. package/__tests__/config.test.ts +34 -34
  15. package/__tests__/configAliases.test.ts +27 -215
  16. package/__tests__/configFileNames.test.ts +118 -0
  17. package/__tests__/e2e/cli.e2e.test.ts +102 -102
  18. package/__tests__/e2e/helpers.ts +5 -5
  19. package/__tests__/effectHelpers.ts +3 -3
  20. package/__tests__/emailVerification.test.ts +31 -0
  21. package/__tests__/oldConfigFiles.test.ts +254 -0
  22. package/__tests__/webhooks.test.ts +2 -2
  23. package/dist/auth/index.d.ts.map +1 -1
  24. package/dist/auth/index.js +6 -43
  25. package/dist/auth/index.js.map +1 -1
  26. package/dist/commands/app/delete.d.ts +2 -2
  27. package/dist/commands/app/delete.d.ts.map +1 -1
  28. package/dist/commands/app/delete.js +2 -2
  29. package/dist/commands/app/delete.js.map +1 -1
  30. package/dist/commands/app/list.d.ts +2 -2
  31. package/dist/commands/app/list.d.ts.map +1 -1
  32. package/dist/commands/app/list.js +2 -2
  33. package/dist/commands/app/list.js.map +1 -1
  34. package/dist/commands/auth/client/add.d.ts +1 -1
  35. package/dist/commands/auth/client/add.d.ts.map +1 -1
  36. package/dist/commands/auth/client/delete.d.ts +2 -2
  37. package/dist/commands/auth/client/delete.d.ts.map +1 -1
  38. package/dist/commands/auth/client/delete.js +2 -2
  39. package/dist/commands/auth/client/delete.js.map +1 -1
  40. package/dist/commands/auth/client/list.d.ts +1 -1
  41. package/dist/commands/auth/client/list.d.ts.map +1 -1
  42. package/dist/commands/auth/client/update.d.ts +1 -1
  43. package/dist/commands/auth/client/update.d.ts.map +1 -1
  44. package/dist/commands/auth/email/pull.d.ts +4 -4
  45. package/dist/commands/auth/email/pull.d.ts.map +1 -1
  46. package/dist/commands/auth/email/pull.js +5 -2
  47. package/dist/commands/auth/email/pull.js.map +1 -1
  48. package/dist/commands/auth/email/push.d.ts +2 -2
  49. package/dist/commands/auth/email/push.d.ts.map +1 -1
  50. package/dist/commands/auth/email/push.js +3 -3
  51. package/dist/commands/auth/email/push.js.map +1 -1
  52. package/dist/commands/auth/email/resend.d.ts +1 -1
  53. package/dist/commands/auth/email/resend.d.ts.map +1 -1
  54. package/dist/commands/auth/email/reset.d.ts +2 -2
  55. package/dist/commands/auth/email/reset.d.ts.map +1 -1
  56. package/dist/commands/auth/email/reset.js +3 -3
  57. package/dist/commands/auth/email/reset.js.map +1 -1
  58. package/dist/commands/auth/email/status.d.ts +4 -4
  59. package/dist/commands/auth/email/status.d.ts.map +1 -1
  60. package/dist/commands/auth/email/status.js +4 -4
  61. package/dist/commands/auth/email/status.js.map +1 -1
  62. package/dist/commands/auth/email/verify.d.ts +1 -1
  63. package/dist/commands/auth/email/verify.d.ts.map +1 -1
  64. package/dist/commands/auth/email/verify.js +1 -1
  65. package/dist/commands/auth/email/verify.js.map +1 -1
  66. package/dist/commands/auth/origin/add.d.ts +1 -1
  67. package/dist/commands/auth/origin/add.d.ts.map +1 -1
  68. package/dist/commands/auth/origin/delete.d.ts +1 -1
  69. package/dist/commands/auth/origin/delete.d.ts.map +1 -1
  70. package/dist/commands/auth/origin/list.d.ts +1 -1
  71. package/dist/commands/auth/origin/list.d.ts.map +1 -1
  72. package/dist/commands/claim.d.ts +2 -2
  73. package/dist/commands/claim.d.ts.map +1 -1
  74. package/dist/commands/claim.js +2 -2
  75. package/dist/commands/claim.js.map +1 -1
  76. package/dist/commands/info.js +2 -2
  77. package/dist/commands/info.js.map +1 -1
  78. package/dist/commands/init.d.ts +1 -1
  79. package/dist/commands/init.d.ts.map +1 -1
  80. package/dist/commands/init.js +3 -0
  81. package/dist/commands/init.js.map +1 -1
  82. package/dist/commands/initWithoutFiles.d.ts.map +1 -1
  83. package/dist/commands/initWithoutFiles.js +7 -3
  84. package/dist/commands/initWithoutFiles.js.map +1 -1
  85. package/dist/commands/login.d.ts +1 -1
  86. package/dist/commands/login.d.ts.map +1 -1
  87. package/dist/commands/pull.d.ts +1 -1
  88. package/dist/commands/pull.d.ts.map +1 -1
  89. package/dist/commands/pull.js +4 -0
  90. package/dist/commands/pull.js.map +1 -1
  91. package/dist/commands/push.d.ts +1 -1
  92. package/dist/commands/push.d.ts.map +1 -1
  93. package/dist/commands/push.js +4 -0
  94. package/dist/commands/push.js.map +1 -1
  95. package/dist/commands/query.d.ts +1 -1
  96. package/dist/commands/query.d.ts.map +1 -1
  97. package/dist/commands/query.js +2 -2
  98. package/dist/commands/query.js.map +1 -1
  99. package/dist/context/authToken.d.ts +2 -2
  100. package/dist/context/authToken.d.ts.map +1 -1
  101. package/dist/context/authToken.js +6 -4
  102. package/dist/context/authToken.js.map +1 -1
  103. package/dist/context/currentApp.d.ts +3 -3
  104. package/dist/context/currentApp.d.ts.map +1 -1
  105. package/dist/context/currentApp.js +20 -20
  106. package/dist/context/currentApp.js.map +1 -1
  107. package/dist/context/globalOpts.d.ts +1 -1
  108. package/dist/context/globalOpts.js +1 -1
  109. package/dist/context/globalOpts.js.map +1 -1
  110. package/dist/context/platformApi.d.ts +3 -3
  111. package/dist/context/platformApi.d.ts.map +1 -1
  112. package/dist/context/platformApi.js +3 -3
  113. package/dist/context/platformApi.js.map +1 -1
  114. package/dist/context/projectInfo.d.ts +4 -4
  115. package/dist/context/projectInfo.d.ts.map +1 -1
  116. package/dist/context/projectInfo.js +12 -18
  117. package/dist/context/projectInfo.js.map +1 -1
  118. package/dist/index.d.ts.map +1 -1
  119. package/dist/index.js +42 -49
  120. package/dist/index.js.map +1 -1
  121. package/dist/layer.d.ts +4 -4
  122. package/dist/layer.d.ts.map +1 -1
  123. package/dist/layer.js +7 -7
  124. package/dist/layer.js.map +1 -1
  125. package/dist/lib/backupDownload.js +1 -1
  126. package/dist/lib/backupDownload.js.map +1 -1
  127. package/dist/lib/config.d.ts +2 -2
  128. package/dist/lib/config.d.ts.map +1 -1
  129. package/dist/lib/config.js +21 -23
  130. package/dist/lib/config.js.map +1 -1
  131. package/dist/lib/createApp.d.ts +2 -2
  132. package/dist/lib/createApp.d.ts.map +1 -1
  133. package/dist/lib/createApp.js +2 -2
  134. package/dist/lib/createApp.js.map +1 -1
  135. package/dist/lib/email.d.ts +38 -6
  136. package/dist/lib/email.d.ts.map +1 -1
  137. package/dist/lib/email.js +22 -13
  138. package/dist/lib/email.js.map +1 -1
  139. package/dist/lib/handleEnv.js +4 -4
  140. package/dist/lib/handleEnv.js.map +1 -1
  141. package/dist/lib/http.d.ts +13 -13
  142. package/dist/lib/http.d.ts.map +1 -1
  143. package/dist/lib/http.js +12 -12
  144. package/dist/lib/http.js.map +1 -1
  145. package/dist/lib/login.d.ts +4 -4
  146. package/dist/lib/login.d.ts.map +1 -1
  147. package/dist/lib/login.js +4 -4
  148. package/dist/lib/login.js.map +1 -1
  149. package/dist/lib/oauth.d.ts +10 -10
  150. package/dist/lib/oauth.d.ts.map +1 -1
  151. package/dist/lib/oauth.js +7 -7
  152. package/dist/lib/oauth.js.map +1 -1
  153. package/dist/lib/platformApi.d.ts +2 -2
  154. package/dist/lib/platformApi.d.ts.map +1 -1
  155. package/dist/lib/platformApi.js +2 -2
  156. package/dist/lib/platformApi.js.map +1 -1
  157. package/dist/lib/pullPerms.d.ts +2 -2
  158. package/dist/lib/pullPerms.d.ts.map +1 -1
  159. package/dist/lib/pullPerms.js +7 -4
  160. package/dist/lib/pullPerms.js.map +1 -1
  161. package/dist/lib/pullSchema.d.ts +2 -2
  162. package/dist/lib/pullSchema.d.ts.map +1 -1
  163. package/dist/lib/pullSchema.js +8 -5
  164. package/dist/lib/pullSchema.js.map +1 -1
  165. package/dist/lib/pushPerms.d.ts +2 -2
  166. package/dist/lib/pushPerms.d.ts.map +1 -1
  167. package/dist/lib/pushPerms.js +6 -3
  168. package/dist/lib/pushPerms.js.map +1 -1
  169. package/dist/lib/pushSchema.d.ts +2 -2
  170. package/dist/lib/pushSchema.d.ts.map +1 -1
  171. package/dist/lib/pushSchema.js +18 -7
  172. package/dist/lib/pushSchema.js.map +1 -1
  173. package/dist/lib/webhooks.d.ts +1 -1
  174. package/dist/lib/webhooks.d.ts.map +1 -1
  175. package/dist/old.js +9 -9
  176. package/dist/old.js.map +1 -1
  177. package/dist/renderSchemaPlan.d.ts +2 -2
  178. package/dist/renderSchemaPlan.d.ts.map +1 -1
  179. package/dist/renderSchemaPlan.js.map +1 -1
  180. package/dist/util/findConfigCandidates.d.ts +0 -20
  181. package/dist/util/findConfigCandidates.d.ts.map +1 -1
  182. package/dist/util/findConfigCandidates.js +44 -63
  183. package/dist/util/findConfigCandidates.js.map +1 -1
  184. package/dist/util/getAppName.d.ts +2 -2
  185. package/dist/util/getAppName.d.ts.map +1 -1
  186. package/dist/util/getAppName.js +2 -2
  187. package/dist/util/getAppName.js.map +1 -1
  188. package/dist/util/isHeadlessEnvironment.js +1 -1
  189. package/dist/util/isHeadlessEnvironment.js.map +1 -1
  190. package/dist/util/loadConfig.d.ts.map +1 -1
  191. package/dist/util/loadConfig.js +4 -11
  192. package/dist/util/loadConfig.js.map +1 -1
  193. package/dist/util/loadEnv.d.ts.map +1 -1
  194. package/dist/util/loadEnv.js +0 -6
  195. package/dist/util/loadEnv.js.map +1 -1
  196. package/dist/util/oldConfigFiles.d.ts +30 -0
  197. package/dist/util/oldConfigFiles.d.ts.map +1 -0
  198. package/dist/util/oldConfigFiles.js +104 -0
  199. package/dist/util/oldConfigFiles.js.map +1 -0
  200. package/dist/util/projectDir.d.ts +1 -1
  201. package/dist/util/projectDir.d.ts.map +1 -1
  202. package/dist/util/projectDir.js +6 -9
  203. package/dist/util/projectDir.js.map +1 -1
  204. package/dist/util/sidekickConfig.d.ts +9 -0
  205. package/dist/util/sidekickConfig.d.ts.map +1 -0
  206. package/dist/util/sidekickConfig.js +18 -0
  207. package/dist/util/sidekickConfig.js.map +1 -0
  208. package/package.json +6 -7
  209. package/src/auth/index.ts +6 -54
  210. package/src/commands/app/delete.ts +2 -2
  211. package/src/commands/app/list.ts +2 -2
  212. package/src/commands/auth/client/delete.ts +2 -2
  213. package/src/commands/auth/email/pull.ts +5 -2
  214. package/src/commands/auth/email/push.ts +3 -3
  215. package/src/commands/auth/email/reset.ts +5 -3
  216. package/src/commands/auth/email/status.ts +4 -4
  217. package/src/commands/auth/email/verify.ts +1 -1
  218. package/src/commands/claim.ts +2 -2
  219. package/src/commands/info.ts +2 -2
  220. package/src/commands/init.ts +3 -0
  221. package/src/commands/initWithoutFiles.ts +13 -6
  222. package/src/commands/pull.ts +6 -0
  223. package/src/commands/push.ts +6 -0
  224. package/src/commands/query.ts +2 -2
  225. package/src/context/authToken.ts +9 -5
  226. package/src/context/currentApp.ts +20 -20
  227. package/src/context/globalOpts.ts +1 -1
  228. package/src/context/platformApi.ts +3 -3
  229. package/src/context/projectInfo.ts +13 -20
  230. package/src/index.ts +42 -52
  231. package/src/layer.ts +10 -10
  232. package/src/lib/backupDownload.ts +1 -1
  233. package/src/lib/config.ts +21 -23
  234. package/src/lib/createApp.ts +2 -2
  235. package/src/lib/email.ts +30 -15
  236. package/src/lib/handleEnv.ts +4 -4
  237. package/src/lib/http.ts +28 -24
  238. package/src/lib/login.ts +4 -4
  239. package/src/lib/oauth.ts +7 -7
  240. package/src/lib/platformApi.ts +2 -2
  241. package/src/lib/pullPerms.ts +7 -4
  242. package/src/lib/pullSchema.ts +9 -6
  243. package/src/lib/pushPerms.ts +6 -3
  244. package/src/lib/pushSchema.ts +19 -7
  245. package/src/old.js +9 -9
  246. package/src/renderSchemaPlan.ts +3 -3
  247. package/src/util/findConfigCandidates.ts +45 -71
  248. package/src/util/getAppName.ts +2 -2
  249. package/src/util/isHeadlessEnvironment.ts +1 -1
  250. package/src/util/loadConfig.ts +4 -12
  251. package/src/util/loadEnv.ts +0 -8
  252. package/src/util/oldConfigFiles.ts +132 -0
  253. package/src/util/projectDir.ts +7 -9
  254. package/src/util/sidekickConfig.ts +25 -0
  255. package/__tests__/legacyPackageCompat.test.ts +0 -104
  256. package/dist/util/envAliases.d.ts +0 -25
  257. package/dist/util/envAliases.d.ts.map +0 -1
  258. package/dist/util/envAliases.js +0 -47
  259. package/dist/util/envAliases.js.map +0 -1
  260. package/dist/util/instantConfig.d.ts +0 -9
  261. package/dist/util/instantConfig.d.ts.map +0 -1
  262. package/dist/util/instantConfig.js +0 -13
  263. package/dist/util/instantConfig.js.map +0 -1
  264. package/src/util/envAliases.ts +0 -53
  265. package/src/util/instantConfig.ts +0 -21
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oldConfigFiles.js","sourceRoot":"","sources":["../../src/util/oldConfigFiles.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,wEAAwE;AACxE,yEAAyE;AACzE,yEAAyE;AACzE,0EAA0E;AAC1E,wEAAwE;AACxE,6DAA6D;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,UAAU,GAAG,KAAK,GAAG,OAAO,CAAC;AAEnC,M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,GAAG,EAAE,GAAG,CAAC,CAAC;oBACpC,MAAM,EAAE,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;iBACpC,CAAC;QACN,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,KAAa,EACb,MAAc,EACd,IAAoB;IAEpB,uEAAuE;IACvE,MAAM,OAAO,GAAG,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,iCAAiC,CAAC;IAC3E,OAAO,IAAI,kBAAkB,CAAC;QAC5B,OAAO,EAAE,SAAS,KAAK,oDAAoD,MAAM,GAAG,OAAO,GAAG;KAC/F,CAAC,CAAC;AACL,CAAC;AAED,6EAA6E;AAC7E,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,KAAuB,EACvB,SAAkB,EAClB,EAAE,CACF,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,iBAAiB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC/C,IAAI,GAAG;YAAE,OAAO,KAAK,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACzE,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["// SidekickDB: the CLI reads its config files only under their sidekick.*\n// names. A project that still has a file under the name from before the\n// rename stops with a message that names both files, instead of the file\n// being ignored (push would report it missing, pull would write a second\n// file next to it). Only the old file's existence is checked; it is never\n// read. The old prefix is spelled in two parts so that the rename rules\n// leave it alone. Everything for this check is in this file.\nimport { statSync } from 'node:fs';\nimport { basename, dirname, join, parse, relative } from 'node:path';\nimport { Data, Effect } from 'effect';\nimport {\n getEmailReadCandidates,\n getPermsReadCandidates,\n getSchemaReadCandidates,\n} from './findConfigCandidates.ts';\n\nconst OLD_PREFIX = 'ins' + 'tant.';\n\nexport class OldConfigFileError extends Data.TaggedError('OldConfigFileError')<{\n message: string;\n}> {}\n\nexport type ConfigFileKind = 'schema' | 'perms' | 'email' | 'config';\n\nconst CONFIG_CANDIDATE = {\n files: 'sidekick.config',\n extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs', 'json'],\n};\n\nfunction candidates(kind: ConfigFileKind, emailPath?: string) {\n switch (kind) {\n case 'schema':\n return getSchemaReadCandidates();\n case 'perms':\n return getPermsReadCandidates();\n case 'email':\n return getEmailReadCandidates(emailPath);\n case 'config':\n return [CONFIG_CANDIDATE];\n }\n}\n\nconst isFile = (path: string) => {\n try {\n return statSync(path).isFile();\n } catch {\n return false;\n }\n};\n\n// The directories the loader (unconfig's findUp) searches: the working\n// directory and each parent, up to but not including the filesystem root.\nfunction searchedDirs(cwd: string) {\n const root = parse(cwd).root;\n const dirs: string[] = [];\n let current = cwd;\n while (current && current !== root) {\n dirs.push(current);\n const parent = dirname(current);\n if (parent === current) break;\n current = parent;\n }\n return dirs;\n}\n\n/**\n * The old-named file to rename and its new name. The search covers the same\n * directories and candidate places as the loader, but level by level: at\n * each directory, from the working directory up, a sidekick.* file of this\n * kind ends it, otherwise an old-named one at one of those places is\n * reported. The loader goes candidate by candidate instead (each candidate\n * through every level, the first with a match wins), so it may load a\n * sidekick.* file further up than an old-named one this reports. That errs\n * on the safe side: it stops whenever an old-named file is nearer than every\n * sidekick.* file. An explicit path (an environment variable, --file) is used\n * as given, so it is not checked.\n */\nexport function findOldConfigFile(\n kind: ConfigFileKind,\n emailPath?: string,\n): { found: string; rename: string } | null {\n if (\n kind !== 'config' &&\n (emailPath || process.env[`SIDEKICK_${kind.toUpperCase()}_FILE_PATH`])\n )\n return null;\n const list = candidates(kind, emailPath);\n if (list.some((c) => !c.extensions)) return null;\n const cwd = process.cwd();\n const paths = list.flatMap((c) =>\n c.extensions!.map((ext) => `${c.files}.${ext}`),\n );\n for (const dir of searchedDirs(cwd)) {\n if (paths.some((p) => isFile(join(dir, p)))) return null;\n for (const p of paths) {\n const old = join(\n dirname(p),\n basename(p).replace(/^sidekick\\./, OLD_PREFIX),\n );\n if (isFile(join(dir, old)))\n return {\n found: relative(cwd, join(dir, old)),\n rename: relative(cwd, join(dir, p)),\n };\n }\n }\n return null;\n}\n\nexport function oldConfigFileError(\n found: string,\n rename: string,\n kind: ConfigFileKind,\n) {\n // Nothing imports the config file; the others are imported by the app.\n const imports = kind === 'config' ? '' : ' (and update the imports of it)';\n return new OldConfigFileError({\n message: `Found ${found}, which SidekickDB no longer reads. Rename it to ${rename}${imports}.`,\n });\n}\n\n/** Fails with OldConfigFileError for the first kind that has an old file. */\nexport const failOnOldConfigFiles = (\n kinds: ConfigFileKind[],\n emailPath?: string,\n) =>\n Effect.gen(function* () {\n for (const kind of kinds) {\n const old = findOldConfigFile(kind, emailPath);\n if (old) return yield* oldConfigFileError(old.found, old.rename, kind);\n }\n });\n"]}
@@ -1,4 +1,4 @@
1
- export type ProjectType = 'node' | 'deno' | 'python';
1
+ export type ProjectType = 'node' | 'deno';
2
2
  export interface ProjectInfo {
3
3
  dir: string;
4
4
  type: ProjectType;
@@ -1 +1 @@
1
- {"version":3,"file":"projectDir.d.ts","sourceRoot":"","sources":["../../src/util/projectDir.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AAErD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,WAAW,CAAC;CACnB;AAYD,wBAAsB,cAAc,CAClC,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CA8B7B"}
1
+ {"version":3,"file":"projectDir.d.ts","sourceRoot":"","sources":["../../src/util/projectDir.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1C,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,WAAW,CAAC;CACnB;AAYD,wBAAsB,cAAc,CAClC,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CA4B7B"}
@@ -1,19 +1,18 @@
1
1
  import { packageDirectory } from 'package-directory';
2
2
  import { findUp } from 'find-up-simple';
3
3
  import path from 'node:path';
4
- // Same-directory tie-breaker: Deno > Python > Node. Deno may coexist
5
- // with package.json for npm interop; pyproject.toml signals Python.
4
+ // Same-directory tie-breaker: Deno > Node. Deno may coexist with
5
+ // package.json for npm interop.
6
+ // SidekickDB: no Python project type, the Python SDK is removed.
6
7
  const TYPE_PRIORITY = {
7
8
  deno: 0,
8
- python: 1,
9
- node: 2,
9
+ node: 1,
10
10
  };
11
11
  const depth = (filepath) => filepath.split(path.sep).length;
12
12
  export async function findProjectDir(cwd) {
13
- const [denoJson, denoJsonc, pyproject, nodeDir] = await Promise.all([
13
+ const [denoJson, denoJsonc, nodeDir] = await Promise.all([
14
14
  findUp('deno.json', { cwd }),
15
15
  findUp('deno.jsonc', { cwd }),
16
- findUp('pyproject.toml', { cwd }),
17
16
  packageDirectory({ cwd }),
18
17
  ]);
19
18
  // Push deno.json and deno.jsonc independently so the depth-sort can
@@ -23,14 +22,12 @@ export async function findProjectDir(cwd) {
23
22
  candidates.push({ file: denoJson, type: 'deno' });
24
23
  if (denoJsonc)
25
24
  candidates.push({ file: denoJsonc, type: 'deno' });
26
- if (pyproject)
27
- candidates.push({ file: pyproject, type: 'python' });
28
25
  if (nodeDir) {
29
26
  candidates.push({ file: path.join(nodeDir, 'package.json'), type: 'node' });
30
27
  }
31
28
  if (candidates.length === 0)
32
29
  return null;
33
- // Nearest marker wins (deepest path), so a Python project nested in a
30
+ // Nearest marker wins (deepest path), so a Deno project nested in a
34
31
  // Node monorepo isn't misclassified by a parent's package.json.
35
32
  candidates.sort((a, b) => {
36
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AC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IACpE,IAAI,OAAO,EAAE,CAAC;QACZ,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAEzC,sEAAsE;IACtE,gEAAgE;IAChE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACvB,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAChD,OAAO,SAAS,KAAK,CAAC;YACpB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7E,CAAC","sourcesContent":["import { packageDirectory } from 'package-directory';\nimport { findUp } from 'find-up-simple';\nimport path from 'node:path';\n\nexport type ProjectType = 'node' | 'deno' | 'python';\n\nexport interface ProjectInfo {\n dir: string;\n type: ProjectType;\n}\n\n// Same-directory tie-breaker: Deno > Python > Node. Deno may coexist\n// with package.json for npm interop; pyproject.toml signals Python.\nconst TYPE_PRIORITY: Record<ProjectType, number> = {\n deno: 0,\n python: 1,\n node: 2,\n};\n\nconst depth = (filepath: string) => filepath.split(path.sep).length;\n\nexport async function findProjectDir(\n cwd?: string,\n): Promise<ProjectInfo | null> {\n const [denoJson, denoJsonc, pyproject, nodeDir] = await Promise.all([\n findUp('deno.json', { cwd }),\n findUp('deno.jsonc', { cwd }),\n findUp('pyproject.toml', { cwd }),\n packageDirectory({ cwd }),\n ]);\n\n // Push deno.json and deno.jsonc independently so the depth-sort can\n // pick the nearer one when both exist at different levels.\n const candidates: { file: string; type: ProjectType }[] = [];\n if (denoJson) candidates.push({ file: denoJson, type: 'deno' });\n if (denoJsonc) candidates.push({ file: denoJsonc, type: 'deno' });\n if (pyproject) candidates.push({ file: pyproject, type: 'python' });\n if (nodeDir) {\n candidates.push({ file: path.join(nodeDir, 'package.json'), type: 'node' });\n }\n\n if (candidates.length === 0) return null;\n\n // Nearest marker wins (deepest path), so a Python project nested in a\n // Node monorepo isn't misclassified by a parent's package.json.\n candidates.sort((a, b) => {\n const depthDiff = depth(b.file) - depth(a.file);\n return depthDiff !== 0\n ? depthDiff\n : TYPE_PRIORITY[a.type] - TYPE_PRIORITY[b.type];\n });\n\n return { dir: path.dirname(candidates[0].file), type: candidates[0].type };\n}\n"]}
1
+ {"version":3,"file":"projectDir.js","sourceRoot":"","sources":["../../src/util/projectDir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAS7B,iEAAiE;AACjE,gCAAgC;AAChC,iEAAiE;AACjE,MAAM,aAAa,GAAgC;IACjD,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;CACR,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;AAEpE,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAAY;IAEZ,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,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AAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7E,CAAC","sourcesContent":["import { packageDirectory } from 'package-directory';\nimport { findUp } from 'find-up-simple';\nimport path from 'node:path';\n\nexport type ProjectType = 'node' | 'deno';\n\nexport interface ProjectInfo {\n dir: string;\n type: ProjectType;\n}\n\n// Same-directory tie-breaker: Deno > Node. Deno may coexist with\n// package.json for npm interop.\n// SidekickDB: no Python project type, the Python SDK is removed.\nconst TYPE_PRIORITY: Record<ProjectType, number> = {\n deno: 0,\n node: 1,\n};\n\nconst depth = (filepath: string) => filepath.split(path.sep).length;\n\nexport async function findProjectDir(\n cwd?: string,\n): Promise<ProjectInfo | null> {\n const [denoJson, denoJsonc, nodeDir] = await Promise.all([\n findUp('deno.json', { cwd }),\n findUp('deno.jsonc', { cwd }),\n packageDirectory({ cwd }),\n ]);\n\n // Push deno.json and deno.jsonc independently so the depth-sort can\n // pick the nearer one when both exist at different levels.\n const candidates: { file: string; type: ProjectType }[] = [];\n if (denoJson) candidates.push({ file: denoJson, type: 'deno' });\n if (denoJsonc) candidates.push({ file: denoJsonc, type: 'deno' });\n if (nodeDir) {\n candidates.push({ file: path.join(nodeDir, 'package.json'), type: 'node' });\n }\n\n if (candidates.length === 0) return null;\n\n // Nearest marker wins (deepest path), so a Deno project nested in a\n // Node monorepo isn't misclassified by a parent's package.json.\n candidates.sort((a, b) => {\n const depthDiff = depth(b.file) - depth(a.file);\n return depthDiff !== 0\n ? depthDiff\n : TYPE_PRIORITY[a.type] - TYPE_PRIORITY[b.type];\n });\n\n return { dir: path.dirname(candidates[0].file), type: candidates[0].type };\n}\n"]}
@@ -0,0 +1,9 @@
1
+ export type SidekickConfig = {
2
+ apiURI?: string;
3
+ dashURI?: string;
4
+ apps?: Record<string, {
5
+ id: string;
6
+ }>;
7
+ };
8
+ export declare function readSidekickConfigFile(): Promise<SidekickConfig>;
9
+ //# sourceMappingURL=sidekickConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sidekickConfig.d.ts","sourceRoot":"","sources":["../../src/util/sidekickConfig.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACvC,CAAC;AAEF,wBAAsB,sBAAsB,4BAc3C"}
@@ -0,0 +1,18 @@
1
+ import { loadConfig } from "./loadConfig.js";
2
+ // SidekickDB: stop when only an old-named config file exists.
3
+ import { findOldConfigFile, oldConfigFileError } from "./oldConfigFiles.js";
4
+ export async function readSidekickConfigFile() {
5
+ const old = findOldConfigFile('config');
6
+ if (old)
7
+ throw oldConfigFileError(old.found, old.rename, 'config');
8
+ return (await loadConfig({
9
+ sources: [
10
+ {
11
+ files: 'sidekick.config',
12
+ extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs', 'json'],
13
+ },
14
+ ],
15
+ merge: false,
16
+ })).config;
17
+ }
18
+ //# sourceMappingURL=sidekickConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sidekickConfig.js","sourceRoot":"","sources":["../../src/util/sidekickConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,8DAA8D;AAC9D,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAQ5E,MAAM,CAAC,KAAK,UAAU,sBAAsB;IAC1C,MAAM,GAAG,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,GAAG;QAAE,MAAM,kBAAkB,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACnE,OAAO,CACL,MAAM,UAAU,CAAiB;QAC/B,OAAO,EAAE;YACP;gBACE,KAAK,EAAE,iBAAiB;gBACxB,UAAU,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC;aAC7D;SACF;QACD,KAAK,EAAE,KAAK;KACb,CAAC,CACH,CAAC,MAAM,CAAC;AACX,CAAC","sourcesContent":["import { loadConfig } from './loadConfig.ts';\n// SidekickDB: stop when only an old-named config file exists.\nimport { findOldConfigFile, oldConfigFileError } from './oldConfigFiles.ts';\n\nexport type SidekickConfig = {\n apiURI?: string;\n dashURI?: string;\n apps?: Record<string, { id: string }>;\n};\n\nexport async function readSidekickConfigFile() {\n const old = findOldConfigFile('config');\n if (old) throw oldConfigFileError(old.found, old.rename, 'config');\n return (\n await loadConfig<SidekickConfig>({\n sources: [\n {\n files: 'sidekick.config',\n extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs', 'json'],\n },\n ],\n merge: false,\n })\n ).config;\n}\n"]}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@sidekickdb/cli",
3
3
  "type": "module",
4
- "version": "2.0.0",
4
+ "version": "3.0.0",
5
5
  "description": "SidekickDB's CLI",
6
6
  "license": "Apache-2.0",
7
- "homepage": "https://github.com/SidekickDB/sidekick/tree/main/client/packages/cli",
7
+ "homepage": "https://sidekickdb.co/docs/cli",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/SidekickDB/sidekick.git",
@@ -28,8 +28,7 @@
28
28
  }
29
29
  },
30
30
  "bin": {
31
- "sidekick-cli": "bin/index.js",
32
- "instant-cli": "bin/index.js"
31
+ "sidekick-cli": "bin/index.js"
33
32
  },
34
33
  "dependencies": {
35
34
  "@commander-js/extra-typings": "^14.0.0",
@@ -61,9 +60,9 @@
61
60
  "strip-ansi": "^7.1.2",
62
61
  "supports-hyperlinks": "^4.4.0",
63
62
  "unconfig": "^7.5.0",
64
- "@sidekickdb/core": "2.0.0",
65
- "@sidekickdb/platform": "2.0.0",
66
- "@sidekickdb/version": "2.0.0"
63
+ "@sidekickdb/core": "3.0.0",
64
+ "@sidekickdb/platform": "3.0.0",
65
+ "@sidekickdb/version": "3.0.0"
67
66
  },
68
67
  "devDependencies": {
69
68
  "@babel/core": "^7.17.9",
package/src/auth/index.ts CHANGED
@@ -3,9 +3,6 @@ import { mkdir, readFile, unlink, writeFile } from 'node:fs/promises';
3
3
  import { dirname, join } from 'node:path';
4
4
  import envPaths from 'env-paths';
5
5
 
6
- const CLOUD_API_URI = 'https://api.instantdb.com';
7
- const LOCAL_API_URI = 'http://localhost:8888';
8
-
9
6
  function normalizeApiURI(apiURI: string) {
10
7
  const url = new URL(apiURI);
11
8
  if (url.protocol !== 'http:' && url.protocol !== 'https:') {
@@ -24,27 +21,11 @@ function getAuthConfigFilePath(apiURI: string) {
24
21
  const backendKey = createHash('sha256')
25
22
  .update(normalizedApiURI)
26
23
  .digest('hex');
27
- const { config: configDir } = envPaths('instantdb-prod');
24
+ const { config: configDir } = envPaths('sidekick');
28
25
 
29
26
  return join(configDir, 'auth', backendKey);
30
27
  }
31
28
 
32
- function getLegacyAuthConfigFilePath(apiURI: string) {
33
- const normalizedApiURI = normalizeApiURI(apiURI);
34
- const legacyConfigName =
35
- normalizedApiURI === CLOUD_API_URI
36
- ? 'instantdb-prod'
37
- : normalizedApiURI === LOCAL_API_URI
38
- ? 'instantdb-dev'
39
- : null;
40
-
41
- if (!legacyConfigName) {
42
- return null;
43
- }
44
-
45
- return join(envPaths(legacyConfigName).config, 'a');
46
- }
47
-
48
29
  async function readFileOrNull(filePath: string) {
49
30
  try {
50
31
  return (await readFile(filePath, 'utf8')).trim();
@@ -56,37 +37,14 @@ async function readFileOrNull(filePath: string) {
56
37
  }
57
38
  }
58
39
 
40
+ // SidekickDB: tokens are stored per backend only; there is no older
41
+ // location to read.
59
42
  export async function readAuthToken(apiURI: string) {
60
- const authConfigFilePath = getAuthConfigFilePath(apiURI);
61
- const authToken = await readFileOrNull(authConfigFilePath);
62
- if (authToken) {
63
- return authToken;
64
- }
65
-
66
- const legacyPath = getLegacyAuthConfigFilePath(apiURI);
67
- if (!legacyPath) {
68
- return null;
69
- }
70
-
71
- const legacyAuthToken = await readFileOrNull(legacyPath);
72
- if (!legacyAuthToken) {
73
- return null;
74
- }
75
-
76
- await writeAuthTokenFile(authConfigFilePath, legacyAuthToken).catch(
77
- () => undefined,
78
- );
79
- return legacyAuthToken;
43
+ return (await readFileOrNull(getAuthConfigFilePath(apiURI))) || null;
80
44
  }
81
45
 
82
46
  export async function writeAuthToken(apiURI: string, authToken: string) {
83
- const authConfigFilePath = getAuthConfigFilePath(apiURI);
84
- await writeAuthTokenFile(authConfigFilePath, authToken);
85
-
86
- const legacyPath = getLegacyAuthConfigFilePath(apiURI);
87
- if (legacyPath) {
88
- await writeAuthTokenFile(legacyPath, authToken).catch(() => undefined);
89
- }
47
+ await writeAuthTokenFile(getAuthConfigFilePath(apiURI), authToken);
90
48
  }
91
49
 
92
50
  async function writeAuthTokenFile(filePath: string, authToken: string) {
@@ -95,13 +53,7 @@ async function writeAuthTokenFile(filePath: string, authToken: string) {
95
53
  }
96
54
 
97
55
  export async function removeAuthToken(apiURI: string) {
98
- const authConfigFilePath = getAuthConfigFilePath(apiURI);
99
- const legacyPath = getLegacyAuthConfigFilePath(apiURI);
100
- const paths = legacyPath
101
- ? [authConfigFilePath, legacyPath]
102
- : [authConfigFilePath];
103
- const removed = await Promise.all(paths.map(removeFileIfExists));
104
- return removed.some(Boolean);
56
+ return removeFileIfExists(getAuthConfigFilePath(apiURI));
105
57
  }
106
58
 
107
59
  async function removeFileIfExists(filePath: string) {
@@ -2,7 +2,7 @@ import { HttpClientResponse } from '@effect/platform';
2
2
  import { Effect, Schema } from 'effect';
3
3
  import type { appDeleteDef, OptsFromCommand } from '../../index.ts';
4
4
  import { GlobalOpts } from '../../context/globalOpts.ts';
5
- import { InstantHttpAuthed, withCommand } from '../../lib/http.ts';
5
+ import { SidekickHttpAuthed, withCommand } from '../../lib/http.ts';
6
6
  import { runUIEffect } from '../../lib/ui.ts';
7
7
  import { UI } from '../../ui/index.ts';
8
8
  import { BadArgsError } from '../../errors.ts';
@@ -28,7 +28,7 @@ const getEnvAppId = () => {
28
28
  export const appDeleteCommand = Effect.fn(function* (
29
29
  opts: OptsFromCommand<typeof appDeleteDef>,
30
30
  ) {
31
- const http = (yield* InstantHttpAuthed).pipe(withCommand('app delete'));
31
+ const http = (yield* SidekickHttpAuthed).pipe(withCommand('app delete'));
32
32
  const { yes } = yield* GlobalOpts;
33
33
  const targetApp = opts.app ?? getEnvAppId();
34
34
 
@@ -1,6 +1,6 @@
1
1
  import { HttpClientResponse } from '@effect/platform';
2
2
  import { Effect, Schema } from 'effect';
3
- import { InstantHttpAuthed } from '../../lib/http.ts';
3
+ import { SidekickHttpAuthed } from '../../lib/http.ts';
4
4
  import chalk from 'chalk';
5
5
  import stringWidth from 'string-width';
6
6
 
@@ -18,7 +18,7 @@ const pad = (value: string, width: number) =>
18
18
 
19
19
  export const appListCommand = (opts: { json?: boolean }) =>
20
20
  Effect.gen(function* () {
21
- const http = yield* InstantHttpAuthed;
21
+ const http = yield* SidekickHttpAuthed;
22
22
  const dashData = yield* http.get('/dash').pipe(
23
23
  Effect.flatMap(HttpClientResponse.schemaBodyJson(DashResponse)),
24
24
  Effect.mapError((e) => new Error("Couldn't get apps.", { cause: e })),
@@ -6,7 +6,7 @@ import { GlobalOpts } from '../../../context/globalOpts.ts';
6
6
  import { runUIEffect } from '../../../lib/ui.ts';
7
7
  import { UI } from '../../../ui/index.ts';
8
8
  import chalk from 'chalk';
9
- import { InstantHttpAuthed, withCommand } from '../../../lib/http.ts';
9
+ import { SidekickHttpAuthed, withCommand } from '../../../lib/http.ts';
10
10
  import { CurrentApp } from '../../../context/currentApp.ts';
11
11
 
12
12
  export const authClientDeleteCmd = Effect.fn(function* (
@@ -51,7 +51,7 @@ export const authClientDeleteCmd = Effect.fn(function* (
51
51
  });
52
52
 
53
53
  const deleteOauthClient = Effect.fn(function* (clientDatabaseId: string) {
54
- const http = (yield* InstantHttpAuthed).pipe(
54
+ const http = (yield* SidekickHttpAuthed).pipe(
55
55
  withCommand('auth client delete'),
56
56
  );
57
57
  const { appId } = yield* CurrentApp;
@@ -9,9 +9,10 @@ import { writeTypescript } from '../../../lib/pullSchema.ts';
9
9
  import { promptOk } from '../../../lib/ui.ts';
10
10
  import { getEmailTemplateStatus, type EmailTemplateInfo } from './status.ts';
11
11
  import type { authEmailPullDef, OptsFromCommand } from '../../../index.ts';
12
- import { InstantHttp } from '../../../lib/http.ts';
12
+ import { SidekickHttp } from '../../../lib/http.ts';
13
13
  import { getAppName } from '../../../util/getAppName.ts';
14
14
  import type { EmailConfig } from '../../../lib/email.ts';
15
+ import { failOnOldConfigFiles } from '../../../util/oldConfigFiles.ts';
15
16
 
16
17
  export const authEmailPullCmd = Effect.fn(function* (
17
18
  opts: OptsFromCommand<typeof authEmailPullDef>,
@@ -44,6 +45,8 @@ export const writeEmailTemplate = (
44
45
  { emailPath, confirmOverwrite = true }: WriteEmailTemplateOpts = {},
45
46
  ) =>
46
47
  Effect.gen(function* () {
48
+ // SidekickDB: stop when only an old-named email file exists.
49
+ yield* failOnOldConfigFiles(['email'], emailPath);
47
50
  const prevEmailFile = yield* Effect.tryPromise({
48
51
  try: () => readLocalEmailFile(emailPath),
49
52
  catch: (e) =>
@@ -86,7 +89,7 @@ const DefaultEmailTemplateSchema = Schema.Struct({
86
89
  });
87
90
 
88
91
  export const getDefaultEmailTemplate = Effect.gen(function* () {
89
- const http = yield* InstantHttp;
92
+ const http = yield* SidekickHttp;
90
93
  const template = yield* http
91
94
  .get('/dash/default-email-template')
92
95
  .pipe(
@@ -6,7 +6,7 @@ import {
6
6
  sendSenderVerification,
7
7
  } from '../../../lib/email.ts';
8
8
  import { CurrentApp } from '../../../context/currentApp.ts';
9
- import { InstantHttpAuthed, withCommand } from '../../../lib/http.ts';
9
+ import { SidekickHttpAuthed, withCommand } from '../../../lib/http.ts';
10
10
  import {
11
11
  HttpClient,
12
12
  HttpClientRequest,
@@ -25,11 +25,11 @@ export const authEmailPushCmd = Effect.fn(function* (
25
25
  ) {
26
26
  const emailConfig = yield* readEmailConfig(opts.file);
27
27
  const { appId } = yield* CurrentApp;
28
- const http = yield* InstantHttpAuthed;
28
+ const http = yield* SidekickHttpAuthed;
29
29
  const authEmail = emailConfig.authEmail;
30
30
  const defTemplate = yield* getDefaultEmailTemplate;
31
31
  const senderEmail =
32
- // If the value in the code is the default instant-owned email, remove it from the request
32
+ // If the value in the code is the server's default email, remove it from the request
33
33
  authEmail.senderEmail === defTemplate.senderEmail
34
34
  ? undefined
35
35
  : emailConfig.authEmail.senderEmail;
@@ -1,13 +1,15 @@
1
1
  import { HttpClientRequest, HttpClientResponse } from '@effect/platform';
2
2
  import { Effect, Schema } from 'effect';
3
3
  import { CurrentApp } from '../../../context/currentApp.ts';
4
- import { InstantHttpAuthed, withCommand } from '../../../lib/http.ts';
4
+ import { SidekickHttpAuthed, withCommand } from '../../../lib/http.ts';
5
5
  import { getDefaultEmailTemplate, writeEmailTemplate } from './pull.ts';
6
6
  import { getEmailTemplateStatus } from './status.ts';
7
7
 
8
8
  export const authEmailResetCmd = Effect.fn(function* () {
9
9
  const { appId } = yield* CurrentApp;
10
- const http = (yield* InstantHttpAuthed).pipe(withCommand('auth email reset'));
10
+ const http = (yield* SidekickHttpAuthed).pipe(
11
+ withCommand('auth email reset'),
12
+ );
11
13
 
12
14
  const status = yield* getEmailTemplateStatus;
13
15
 
@@ -32,6 +34,6 @@ export const authEmailResetCmd = Effect.fn(function* () {
32
34
  });
33
35
 
34
36
  yield* Effect.log(
35
- 'instant.email.ts file reset to default. To apply this change, run sidekick-cli auth email push',
37
+ 'sidekick.email.ts file reset to default. To apply this change, run sidekick-cli auth email push',
36
38
  );
37
39
  });
@@ -3,7 +3,7 @@ import chalk from 'chalk';
3
3
  import { Effect, Option, Schema } from 'effect';
4
4
  import { CurrentApp } from '../../../context/currentApp.ts';
5
5
  import type { authEmailStatusDef, OptsFromCommand } from '../../../index.ts';
6
- import { InstantHttpAuthed } from '../../../lib/http.ts';
6
+ import { SidekickHttpAuthed } from '../../../lib/http.ts';
7
7
  import { HttpClientResponse } from '@effect/platform';
8
8
  import { getVerification } from '../../../lib/email.ts';
9
9
 
@@ -77,7 +77,7 @@ export const EmailTemplateSchema = Schema.Union(
77
77
 
78
78
  export const getEmailTemplateStatus = Effect.gen(function* () {
79
79
  const { appId } = yield* CurrentApp;
80
- const http = yield* InstantHttpAuthed;
80
+ const http = yield* SidekickHttpAuthed;
81
81
 
82
82
  const app = yield* http
83
83
  .get(`/dash/apps/${appId}/email_status`)
@@ -130,13 +130,13 @@ export const emailStatusCmd = Effect.fn(function* (
130
130
  '\n' +
131
131
  boxen(
132
132
  [
133
- `Server verified: ${formatVerified(verification.instant['verified?'])}`,
133
+ `Server verified: ${formatVerified(verification.server['verified?'])}`,
134
134
  `Postmark verified: ${formatVerified(verification.verification?.Confirmed)}`,
135
135
  ].join('\n'),
136
136
  {
137
137
  title: 'Custom Sender Verification',
138
138
  borderColor:
139
- verification.instant['verified?'] &&
139
+ verification.server['verified?'] &&
140
140
  verification.verification?.Confirmed
141
141
  ? 'green'
142
142
  : 'yellow',
@@ -12,7 +12,7 @@ export const verifyCmd = Effect.fn(function* (
12
12
  const verificationInfo = yield* getVerification;
13
13
 
14
14
  if (
15
- verificationInfo.instant['verified?'] &&
15
+ verificationInfo.server['verified?'] &&
16
16
  verificationInfo.verification?.Confirmed
17
17
  ) {
18
18
  yield* Effect.log(
@@ -3,14 +3,14 @@ import chalk from 'chalk';
3
3
  import { Effect } from 'effect';
4
4
  import { CurrentApp } from '../context/currentApp.ts';
5
5
  import { BadArgsError } from '../errors.ts';
6
- import { InstantHttpAuthed } from '../lib/http.ts';
6
+ import { SidekickHttpAuthed } from '../lib/http.ts';
7
7
 
8
8
  export const claimCommand = Effect.gen(function* () {
9
9
  const { appId, adminToken } = yield* CurrentApp;
10
10
 
11
11
  yield* Effect.log(`Found app: ${appId}`);
12
12
 
13
- const http = yield* InstantHttpAuthed;
13
+ const http = yield* SidekickHttpAuthed;
14
14
 
15
15
  if (!adminToken) {
16
16
  return yield* BadArgsError.make({ message: 'Missing app admin token' });
@@ -1,6 +1,6 @@
1
1
  import { HttpClientResponse } from '@effect/platform';
2
2
  import { Effect, Schema, Option } from 'effect';
3
- import { getBaseUrl, InstantHttpAuthed } from '../lib/http.ts';
3
+ import { getBaseUrl, SidekickHttpAuthed } from '../lib/http.ts';
4
4
  import { version } from '@sidekickdb/version';
5
5
  import { CurrentApp } from '../context/currentApp.ts';
6
6
 
@@ -22,7 +22,7 @@ export const DashAppResponse = Schema.Struct({
22
22
  export const infoCommand = () =>
23
23
  Effect.gen(function* () {
24
24
  const baseUrl = yield* getBaseUrl;
25
- const authedHttp = yield* Effect.serviceOption(InstantHttpAuthed).pipe(
25
+ const authedHttp = yield* Effect.serviceOption(SidekickHttpAuthed).pipe(
26
26
  Effect.map(Option.getOrNull),
27
27
  );
28
28
  const maybeApp = yield* Effect.serviceOption(CurrentApp);
@@ -7,9 +7,12 @@ import { pullPerms } from '../lib/pullPerms.ts';
7
7
  import { promptOk } from '../lib/ui.ts';
8
8
  import { pushSchema } from '../lib/pushSchema.ts';
9
9
  import { pushPerms } from '../lib/pushPerms.ts';
10
+ import { failOnOldConfigFiles } from '../util/oldConfigFiles.ts';
10
11
 
11
12
  export const initCommand = (_options: OptsFromCommand<typeof initDef>) =>
12
13
  Effect.gen(function* () {
14
+ // SidekickDB: stop when only old-named schema or perms files exist.
15
+ yield* failOnOldConfigFiles(['schema', 'perms']);
13
16
  yield* Effect.matchEffect(
14
17
  Effect.tryPromise(readLocalSchemaFile).pipe(
15
18
  // Throws NoSuchElementException if no file found
@@ -1,5 +1,5 @@
1
1
  import { Effect } from 'effect';
2
- import { PlatformApi } from '../context/platformApi.ts';
2
+ import { PlatformApi, PlatformApiError } from '../context/platformApi.ts';
3
3
  import { BadArgsError } from '../errors.ts';
4
4
  import { initWithoutFilesDef } from '../index.ts';
5
5
  import type { OptsFromCommand } from '../index.ts';
@@ -33,10 +33,12 @@ export const initWithoutFilesCommand = (
33
33
 
34
34
  if (opts.temp) {
35
35
  const platform = yield* PlatformApi;
36
- const app = yield* platform.use((api) =>
37
- api.createTemporaryApp({
38
- title: opts.title!,
39
- }),
36
+ const app = yield* platform.use(
37
+ (api) =>
38
+ api.createTemporaryApp({
39
+ title: opts.title!,
40
+ }),
41
+ 'Error creating temporary app',
40
42
  );
41
43
 
42
44
  console.error(`${chalk.green('Successfully created new app!')}\n`);
@@ -94,7 +96,12 @@ export const initWithoutFilesCommand = (
94
96
  {
95
97
  app: null,
96
98
  error: {
97
- message: e.message,
99
+ // SidekickDB: include the server's reason, for example when
100
+ // temporary apps are turned off on the server.
101
+ message:
102
+ e instanceof PlatformApiError && e.cause instanceof Error
103
+ ? `${e.message}: ${e.cause.message}`
104
+ : e.message,
98
105
  },
99
106
  },
100
107
  null,
@@ -2,6 +2,7 @@ import { Effect } from 'effect';
2
2
  import type { OptsFromCommand, pullDef } from '../index.ts';
3
3
  import { pullSchema } from '../lib/pullSchema.ts';
4
4
  import { pullPerms } from '../lib/pullPerms.ts';
5
+ import { failOnOldConfigFiles } from '../util/oldConfigFiles.ts';
5
6
 
6
7
  export type SchemaPermsOrBoth = 'schema' | 'perms' | 'all';
7
8
 
@@ -11,6 +12,11 @@ export const pullCommand = (
11
12
  ) =>
12
13
  Effect.gen(function* () {
13
14
  arg ||= 'all';
15
+ // SidekickDB: check every kind this command touches before any request
16
+ // or write, so a half-renamed project changes nothing.
17
+ yield* failOnOldConfigFiles(
18
+ arg === 'all' ? ['schema', 'perms'] : [arg as 'schema' | 'perms'],
19
+ );
14
20
  if (arg === 'schema' || arg === 'all') {
15
21
  yield* pullSchema({
16
22
  experimentalTypePreservation: opts.experimentalTypePreservation,
@@ -4,6 +4,7 @@ import { pushDef } from '../index.ts';
4
4
  import type { OptsFromCommand } from '../index.ts';
5
5
  import { pushPerms } from '../lib/pushPerms.ts';
6
6
  import { pushSchema } from '../lib/pushSchema.ts';
7
+ import { failOnOldConfigFiles } from '../util/oldConfigFiles.ts';
7
8
 
8
9
  export const pushCommand = (
9
10
  arg: string | undefined,
@@ -16,6 +17,11 @@ export const pushCommand = (
16
17
  message: `Invalid argument: ${arg}. Expected one of schema, perms, or all`,
17
18
  });
18
19
  }
20
+ // SidekickDB: check every kind this command touches before any request
21
+ // or write, so a half-renamed project changes nothing.
22
+ yield* failOnOldConfigFiles(
23
+ arg === 'all' ? ['schema', 'perms'] : [arg as 'schema' | 'perms'],
24
+ );
19
25
  if (arg === 'schema' || arg === 'all') {
20
26
  yield* pushSchema(opts.rename);
21
27
  }
@@ -4,7 +4,7 @@ import { queryDef } from '../index.ts';
4
4
  import type { OptsFromCommand } from '../index.ts';
5
5
  import { CurrentApp } from '../context/currentApp.ts';
6
6
  import { BadArgsError } from '../errors.ts';
7
- import { InstantHttpAuthed, withCommand } from '../lib/http.ts';
7
+ import { SidekickHttpAuthed, withCommand } from '../lib/http.ts';
8
8
  import { HttpBody } from '@effect/platform';
9
9
  import { WithAppLayer } from '../layer.ts';
10
10
 
@@ -41,7 +41,7 @@ export const queryCmd = (arg: string, opts: OptsFromCommand<typeof queryDef>) =>
41
41
  headers['as-token'] = opts.asToken;
42
42
  }
43
43
 
44
- const http = (yield* InstantHttpAuthed).pipe(withCommand('query'));
44
+ const http = (yield* SidekickHttpAuthed).pipe(withCommand('query'));
45
45
  const response = yield* http.post('/admin/query', {
46
46
  headers,
47
47
  body: HttpBody.unsafeJson({
@@ -11,7 +11,9 @@ type AuthTokenState = {
11
11
  source: AuthTokenSource;
12
12
  };
13
13
 
14
- export class AuthToken extends Context.Tag('instant-cli/new/context/authToken')<
14
+ export class AuthToken extends Context.Tag(
15
+ 'sidekick-cli/new/context/authToken',
16
+ )<
15
17
  AuthToken,
16
18
  {
17
19
  getAuthToken: Effect.Effect<string>;
@@ -39,7 +41,7 @@ export const authTokenGetEffect = (allowAdminToken: boolean = true) =>
39
41
  };
40
42
  }
41
43
 
42
- const env = yield* Config.string('INSTANT_CLI_AUTH_TOKEN').pipe(
44
+ const env = yield* Config.string('SIDEKICK_CLI_AUTH_TOKEN').pipe(
43
45
  Config.option,
44
46
  Config.map(Option.getOrNull),
45
47
  );
@@ -51,8 +53,8 @@ export const authTokenGetEffect = (allowAdminToken: boolean = true) =>
51
53
  };
52
54
  }
53
55
 
54
- const secondaryEnv = yield* Config.string('INSTANT_APP_ADMIN_TOKEN').pipe(
55
- Config.orElse(() => Config.string('INSTANT_ADMIN_TOKEN')),
56
+ const secondaryEnv = yield* Config.string('SIDEKICK_APP_ADMIN_TOKEN').pipe(
57
+ Config.orElse(() => Config.string('SIDEKICK_ADMIN_TOKEN')),
56
58
  Config.option,
57
59
  Config.map(Option.getOrNull),
58
60
  );
@@ -74,7 +76,9 @@ export const authTokenGetEffect = (allowAdminToken: boolean = true) =>
74
76
  };
75
77
  }
76
78
 
77
- return yield* NotAuthedError.make({ message: 'You are not logged in' });
79
+ return yield* NotAuthedError.make({
80
+ message: 'You are not logged in. Log in with `sidekick-cli login`.',
81
+ });
78
82
  });
79
83
 
80
84
  export const AuthTokenLive = ({