@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,25 @@
1
+ import { loadConfig } from './loadConfig.ts';
2
+ // SidekickDB: stop when only an old-named config file exists.
3
+ import { findOldConfigFile, oldConfigFileError } from './oldConfigFiles.ts';
4
+
5
+ export type SidekickConfig = {
6
+ apiURI?: string;
7
+ dashURI?: string;
8
+ apps?: Record<string, { id: string }>;
9
+ };
10
+
11
+ export async function readSidekickConfigFile() {
12
+ const old = findOldConfigFile('config');
13
+ if (old) throw oldConfigFileError(old.found, old.rename, 'config');
14
+ return (
15
+ await loadConfig<SidekickConfig>({
16
+ sources: [
17
+ {
18
+ files: 'sidekick.config',
19
+ extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs', 'json'],
20
+ },
21
+ ],
22
+ merge: false,
23
+ })
24
+ ).config;
25
+ }
@@ -1,104 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { i } from '@sidekickdb/core';
3
- import {
4
- generatePermsTypescriptFile,
5
- generateSchemaTypescriptFile,
6
- } from '@sidekickdb/platform';
7
- import { getInstantModuleName } from '../src/context/projectInfo.ts';
8
- import { transformImports } from '../src/util/findConfigCandidates.ts';
9
-
10
- const schema = i.schema({
11
- entities: { todos: i.entity({ text: i.string() }) },
12
- });
13
-
14
- describe('getInstantModuleName', () => {
15
- test('a project that only depends on legacy @instantdb/react keeps it', () => {
16
- const moduleName = getInstantModuleName({
17
- dependencies: { '@instantdb/react': '^0.22.0' },
18
- });
19
- expect(moduleName).toBe('@instantdb/react');
20
-
21
- // Generated schema and perms files keep importing the legacy package.
22
- expect(generateSchemaTypescriptFile(null, schema, moduleName!)).toContain(
23
- `import { i } from "@instantdb/react";`,
24
- );
25
- expect(generatePermsTypescriptFile(null, moduleName!)).toContain(
26
- `import type { InstantRules } from "@instantdb/react";`,
27
- );
28
- });
29
-
30
- test('legacy packages in devDependencies are detected too', () => {
31
- expect(
32
- getInstantModuleName({ devDependencies: { '@instantdb/admin': '*' } }),
33
- ).toBe('@instantdb/admin');
34
- });
35
-
36
- test('prefers @sidekickdb/* when both scopes are present', () => {
37
- expect(
38
- getInstantModuleName({
39
- dependencies: {
40
- '@instantdb/react': '^0.22.0',
41
- '@sidekickdb/react': '^1.0.0',
42
- },
43
- }),
44
- ).toBe('@sidekickdb/react');
45
-
46
- // Even when the legacy package comes earlier in the SDK order.
47
- expect(
48
- getInstantModuleName({
49
- dependencies: { '@instantdb/react': '^0.22.0' },
50
- devDependencies: { '@sidekickdb/vue': '^1.0.0' },
51
- }),
52
- ).toBe('@sidekickdb/vue');
53
- });
54
-
55
- test('a project on @sidekickdb/* resolves to it', () => {
56
- expect(
57
- getInstantModuleName({ dependencies: { '@sidekickdb/core': '^1.0.0' } }),
58
- ).toBe('@sidekickdb/core');
59
- });
60
-
61
- test('returns undefined when no SDK is installed', () => {
62
- expect(
63
- getInstantModuleName({ dependencies: { react: '^18.0.0' } }),
64
- ).toBeUndefined();
65
- });
66
- });
67
-
68
- describe('transformImports', () => {
69
- for (const scope of ['@sidekickdb', '@instantdb']) {
70
- for (const pkg of ['react-native', 'svelte', 'vue']) {
71
- test(`rewrites ${scope}/${pkg} to its dist/cli entry, keeping the scope`, () => {
72
- expect(transformImports(`import { i } from '${scope}/${pkg}';`)).toBe(
73
- `import { i } from "${scope}/${pkg}/dist/cli";`,
74
- );
75
- expect(transformImports(`import { i } from "${scope}/${pkg}";`)).toBe(
76
- `import { i } from "${scope}/${pkg}/dist/cli";`,
77
- );
78
- });
79
- }
80
- }
81
-
82
- test('leaves other packages and subpaths alone', () => {
83
- const code = [
84
- `import { i } from '@sidekickdb/react';`,
85
- `import { i as j } from '@instantdb/core';`,
86
- `import { x } from '@instantdb/react-native/dist/cli';`,
87
- `import { y } from '@other/vue';`,
88
- ].join('\n');
89
- expect(transformImports(code)).toBe(code);
90
- });
91
-
92
- test('rewrites mixed-scope imports in one file independently', () => {
93
- const code = [
94
- `import { i } from '@instantdb/vue';`,
95
- `import { id } from '@sidekickdb/svelte';`,
96
- ].join('\n');
97
- expect(transformImports(code)).toBe(
98
- [
99
- `import { i } from "@instantdb/vue/dist/cli";`,
100
- `import { id } from "@sidekickdb/svelte/dist/cli";`,
101
- ].join('\n'),
102
- );
103
- });
104
- });
@@ -1,25 +0,0 @@
1
- /**
2
- * SidekickDB names for environment variables.
3
- *
4
- * Every variable with `INSTANT_` in its name can also be set with `SIDEKICK_`
5
- * in that place: `SIDEKICK_CLI_API_URI` for `INSTANT_CLI_API_URI`,
6
- * `NEXT_PUBLIC_SIDEKICK_APP_ID` for `NEXT_PUBLIC_INSTANT_APP_ID`, and so on.
7
- * The `SIDEKICK_` name wins when both are set; a blank value counts as unset.
8
- *
9
- * The rest of the CLI keeps reading the `INSTANT_` names, so that its source
10
- * stays close to upstream. `applyEnvAliases` copies each `SIDEKICK_` value onto
11
- * its `INSTANT_` name once, right after the env files are loaded.
12
- */
13
- /** `INSTANT_` name that `name` stands for, or null when it is not an alias. */
14
- export declare function legacyEnvName(name: string): string | null;
15
- /**
16
- * Copies every `SIDEKICK_` variable in `env` onto its `INSTANT_` name.
17
- * Returns the names it set, as `INSTANT_` name -> `SIDEKICK_` name.
18
- */
19
- export declare function applyEnvAliases(env?: Record<string, string | undefined>): Record<string, string>;
20
- /**
21
- * The name to show for an `INSTANT_` variable: the `SIDEKICK_` name when the
22
- * value was set under it, otherwise the name itself.
23
- */
24
- export declare function envNameForDisplay(legacyName: string): string;
25
- //# sourceMappingURL=envAliases.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"envAliases.d.ts","sourceRoot":"","sources":["../../src/util/envAliases.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGzD;AAKD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAcxB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE5D"}
@@ -1,47 +0,0 @@
1
- /**
2
- * SidekickDB names for environment variables.
3
- *
4
- * Every variable with `INSTANT_` in its name can also be set with `SIDEKICK_`
5
- * in that place: `SIDEKICK_CLI_API_URI` for `INSTANT_CLI_API_URI`,
6
- * `NEXT_PUBLIC_SIDEKICK_APP_ID` for `NEXT_PUBLIC_INSTANT_APP_ID`, and so on.
7
- * The `SIDEKICK_` name wins when both are set; a blank value counts as unset.
8
- *
9
- * The rest of the CLI keeps reading the `INSTANT_` names, so that its source
10
- * stays close to upstream. `applyEnvAliases` copies each `SIDEKICK_` value onto
11
- * its `INSTANT_` name once, right after the env files are loaded.
12
- */
13
- const SIDEKICK_NAME = /^((?:[A-Z0-9]+_)*?)SIDEKICK_([A-Z0-9_]+)$/;
14
- /** `INSTANT_` name that `name` stands for, or null when it is not an alias. */
15
- export function legacyEnvName(name) {
16
- const match = SIDEKICK_NAME.exec(name);
17
- return match ? `${match[1]}INSTANT_${match[2]}` : null;
18
- }
19
- // INSTANT_ name -> the SIDEKICK_ name its value came from.
20
- const applied = new Map();
21
- /**
22
- * Copies every `SIDEKICK_` variable in `env` onto its `INSTANT_` name.
23
- * Returns the names it set, as `INSTANT_` name -> `SIDEKICK_` name.
24
- */
25
- export function applyEnvAliases(env = process.env) {
26
- const result = {};
27
- for (const [name, value] of Object.entries(env)) {
28
- const legacyName = legacyEnvName(name);
29
- if (!legacyName || value === undefined || value.trim() === '') {
30
- continue;
31
- }
32
- env[legacyName] = value;
33
- result[legacyName] = name;
34
- if (env === process.env) {
35
- applied.set(legacyName, name);
36
- }
37
- }
38
- return result;
39
- }
40
- /**
41
- * The name to show for an `INSTANT_` variable: the `SIDEKICK_` name when the
42
- * value was set under it, otherwise the name itself.
43
- */
44
- export function envNameForDisplay(legacyName) {
45
- return applied.get(legacyName) ?? legacyName;
46
- }
47
- //# sourceMappingURL=envAliases.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"envAliases.js","sourceRoot":"","sources":["../../src/util/envAliases.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,aAAa,GAAG,2CAA2C,CAAC;AAElE,+EAA+E;AAC/E,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACzD,CAAC;AAED,2DAA2D;AAC3D,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,MAA0C,OAAO,CAAC,GAAG;IAErD,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAChD,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,UAAU,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC9D,SAAS;QACX,CAAC;QACD,GAAG,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC;QACxB,MAAM,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;QAC1B,IAAI,GAAG,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC;YACxB,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAkB;IAClD,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC;AAC/C,CAAC","sourcesContent":["/**\n * SidekickDB names for environment variables.\n *\n * Every variable with `INSTANT_` in its name can also be set with `SIDEKICK_`\n * in that place: `SIDEKICK_CLI_API_URI` for `INSTANT_CLI_API_URI`,\n * `NEXT_PUBLIC_SIDEKICK_APP_ID` for `NEXT_PUBLIC_INSTANT_APP_ID`, and so on.\n * The `SIDEKICK_` name wins when both are set; a blank value counts as unset.\n *\n * The rest of the CLI keeps reading the `INSTANT_` names, so that its source\n * stays close to upstream. `applyEnvAliases` copies each `SIDEKICK_` value onto\n * its `INSTANT_` name once, right after the env files are loaded.\n */\n\nconst SIDEKICK_NAME = /^((?:[A-Z0-9]+_)*?)SIDEKICK_([A-Z0-9_]+)$/;\n\n/** `INSTANT_` name that `name` stands for, or null when it is not an alias. */\nexport function legacyEnvName(name: string): string | null {\n const match = SIDEKICK_NAME.exec(name);\n return match ? `${match[1]}INSTANT_${match[2]}` : null;\n}\n\n// INSTANT_ name -> the SIDEKICK_ name its value came from.\nconst applied = new Map<string, string>();\n\n/**\n * Copies every `SIDEKICK_` variable in `env` onto its `INSTANT_` name.\n * Returns the names it set, as `INSTANT_` name -> `SIDEKICK_` name.\n */\nexport function applyEnvAliases(\n env: Record<string, string | undefined> = process.env,\n): Record<string, string> {\n const result: Record<string, string> = {};\n for (const [name, value] of Object.entries(env)) {\n const legacyName = legacyEnvName(name);\n if (!legacyName || value === undefined || value.trim() === '') {\n continue;\n }\n env[legacyName] = value;\n result[legacyName] = name;\n if (env === process.env) {\n applied.set(legacyName, name);\n }\n }\n return result;\n}\n\n/**\n * The name to show for an `INSTANT_` variable: the `SIDEKICK_` name when the\n * value was set under it, otherwise the name itself.\n */\nexport function envNameForDisplay(legacyName: string): string {\n return applied.get(legacyName) ?? legacyName;\n}\n"]}
@@ -1,9 +0,0 @@
1
- export type InstantConfig = {
2
- apiURI?: string;
3
- dashURI?: string;
4
- apps?: Record<string, {
5
- id: string;
6
- }>;
7
- };
8
- export declare function readInstantConfigFile(): Promise<InstantConfig>;
9
- //# sourceMappingURL=instantConfig.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instantConfig.d.ts","sourceRoot":"","sources":["../../src/util/instantConfig.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG;IAC1B,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,qBAAqB,2BAY1C"}
@@ -1,13 +0,0 @@
1
- import { loadConfig } from "./loadConfig.js";
2
- export async function readInstantConfigFile() {
3
- return (await loadConfig({
4
- // sidekick.config.* is the SidekickDB name for instant.config.*. With
5
- // `merge: false` the first source that exists is used, so it wins.
6
- sources: ['sidekick.config', 'instant.config'].map((files) => ({
7
- files,
8
- extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs', 'json'],
9
- })),
10
- merge: false,
11
- })).config;
12
- }
13
- //# sourceMappingURL=instantConfig.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instantConfig.js","sourceRoot":"","sources":["../../src/util/instantConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAQ7C,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,OAAO,CACL,MAAM,UAAU,CAAgB;QAC9B,sEAAsE;QACtE,mEAAmE;QACnE,OAAO,EAAE,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC7D,KAAK;YACL,UAAU,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC;SAC7D,CAAC,CAAC;QACH,KAAK,EAAE,KAAK;KACb,CAAC,CACH,CAAC,MAAM,CAAC;AACX,CAAC","sourcesContent":["import { loadConfig } from './loadConfig.ts';\n\nexport type InstantConfig = {\n apiURI?: string;\n dashURI?: string;\n apps?: Record<string, { id: string }>;\n};\n\nexport async function readInstantConfigFile() {\n return (\n await loadConfig<InstantConfig>({\n // sidekick.config.* is the SidekickDB name for instant.config.*. With\n // `merge: false` the first source that exists is used, so it wins.\n sources: ['sidekick.config', 'instant.config'].map((files) => ({\n files,\n extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs', 'json'],\n })),\n merge: false,\n })\n ).config;\n}\n"]}
@@ -1,53 +0,0 @@
1
- /**
2
- * SidekickDB names for environment variables.
3
- *
4
- * Every variable with `INSTANT_` in its name can also be set with `SIDEKICK_`
5
- * in that place: `SIDEKICK_CLI_API_URI` for `INSTANT_CLI_API_URI`,
6
- * `NEXT_PUBLIC_SIDEKICK_APP_ID` for `NEXT_PUBLIC_INSTANT_APP_ID`, and so on.
7
- * The `SIDEKICK_` name wins when both are set; a blank value counts as unset.
8
- *
9
- * The rest of the CLI keeps reading the `INSTANT_` names, so that its source
10
- * stays close to upstream. `applyEnvAliases` copies each `SIDEKICK_` value onto
11
- * its `INSTANT_` name once, right after the env files are loaded.
12
- */
13
-
14
- const SIDEKICK_NAME = /^((?:[A-Z0-9]+_)*?)SIDEKICK_([A-Z0-9_]+)$/;
15
-
16
- /** `INSTANT_` name that `name` stands for, or null when it is not an alias. */
17
- export function legacyEnvName(name: string): string | null {
18
- const match = SIDEKICK_NAME.exec(name);
19
- return match ? `${match[1]}INSTANT_${match[2]}` : null;
20
- }
21
-
22
- // INSTANT_ name -> the SIDEKICK_ name its value came from.
23
- const applied = new Map<string, string>();
24
-
25
- /**
26
- * Copies every `SIDEKICK_` variable in `env` onto its `INSTANT_` name.
27
- * Returns the names it set, as `INSTANT_` name -> `SIDEKICK_` name.
28
- */
29
- export function applyEnvAliases(
30
- env: Record<string, string | undefined> = process.env,
31
- ): Record<string, string> {
32
- const result: Record<string, string> = {};
33
- for (const [name, value] of Object.entries(env)) {
34
- const legacyName = legacyEnvName(name);
35
- if (!legacyName || value === undefined || value.trim() === '') {
36
- continue;
37
- }
38
- env[legacyName] = value;
39
- result[legacyName] = name;
40
- if (env === process.env) {
41
- applied.set(legacyName, name);
42
- }
43
- }
44
- return result;
45
- }
46
-
47
- /**
48
- * The name to show for an `INSTANT_` variable: the `SIDEKICK_` name when the
49
- * value was set under it, otherwise the name itself.
50
- */
51
- export function envNameForDisplay(legacyName: string): string {
52
- return applied.get(legacyName) ?? legacyName;
53
- }
@@ -1,21 +0,0 @@
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
- }