@sanity/cli-core 0.0.2-alpha.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 (149) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/dist/SanityCommand.d.ts +56 -0
  4. package/dist/SanityCommand.js +72 -0
  5. package/dist/SanityCommand.js.map +1 -0
  6. package/dist/config/__tests__/cliToken.test.js +74 -0
  7. package/dist/config/__tests__/cliToken.test.js.map +1 -0
  8. package/dist/config/__tests__/cliUserConfig.test.js +131 -0
  9. package/dist/config/__tests__/cliUserConfig.test.js.map +1 -0
  10. package/dist/config/__tests__/findProjectRoot.test.js +159 -0
  11. package/dist/config/__tests__/findProjectRoot.test.js.map +1 -0
  12. package/dist/config/cli/getCliConfig.d.ts +16 -0
  13. package/dist/config/cli/getCliConfig.js +67 -0
  14. package/dist/config/cli/getCliConfig.js.map +1 -0
  15. package/dist/config/cli/getCliConfig.worker.d.ts +1 -0
  16. package/dist/config/cli/getCliConfig.worker.js +14 -0
  17. package/dist/config/cli/getCliConfig.worker.js.map +1 -0
  18. package/dist/config/cli/schemas.d.ts +204 -0
  19. package/dist/config/cli/schemas.js +77 -0
  20. package/dist/config/cli/schemas.js.map +1 -0
  21. package/dist/config/cli/types.d.ts +13 -0
  22. package/dist/config/cli/types.js +3 -0
  23. package/dist/config/cli/types.js.map +1 -0
  24. package/dist/config/findProjectRoot.d.ts +14 -0
  25. package/dist/config/findProjectRoot.js +56 -0
  26. package/dist/config/findProjectRoot.js.map +1 -0
  27. package/dist/config/studio/getStudioConfig.d.ts +14 -0
  28. package/dist/config/studio/getStudioConfig.js +16 -0
  29. package/dist/config/studio/getStudioConfig.js.map +1 -0
  30. package/dist/config/studio/readStudioConfig.d.ts +190 -0
  31. package/dist/config/studio/readStudioConfig.js +45 -0
  32. package/dist/config/studio/readStudioConfig.js.map +1 -0
  33. package/dist/config/studio/readStudioConfig.worker.d.ts +1 -0
  34. package/dist/config/studio/readStudioConfig.worker.js +64 -0
  35. package/dist/config/studio/readStudioConfig.worker.js.map +1 -0
  36. package/dist/config/util/findAppConfigPath.d.ts +8 -0
  37. package/dist/config/util/findAppConfigPath.js +22 -0
  38. package/dist/config/util/findAppConfigPath.js.map +1 -0
  39. package/dist/config/util/findConfigsPaths.d.ts +16 -0
  40. package/dist/config/util/findConfigsPaths.js +21 -0
  41. package/dist/config/util/findConfigsPaths.js.map +1 -0
  42. package/dist/config/util/findStudioConfigPath.d.ts +9 -0
  43. package/dist/config/util/findStudioConfigPath.js +31 -0
  44. package/dist/config/util/findStudioConfigPath.js.map +1 -0
  45. package/dist/config/util/isSanityV2StudioRoot.d.ts +8 -0
  46. package/dist/config/util/isSanityV2StudioRoot.js +19 -0
  47. package/dist/config/util/isSanityV2StudioRoot.js.map +1 -0
  48. package/dist/config/util/recursivelyResolveProjectRoot.d.ts +27 -0
  49. package/dist/config/util/recursivelyResolveProjectRoot.js +28 -0
  50. package/dist/config/util/recursivelyResolveProjectRoot.js.map +1 -0
  51. package/dist/debug.d.ts +15 -0
  52. package/dist/debug.js +15 -0
  53. package/dist/debug.js.map +1 -0
  54. package/dist/index.d.ts +28 -0
  55. package/dist/index.js +27 -0
  56. package/dist/index.js.map +1 -0
  57. package/dist/loaders/studio/stubs.d.ts +254 -0
  58. package/dist/loaders/studio/stubs.js +257 -0
  59. package/dist/loaders/studio/stubs.js.map +1 -0
  60. package/dist/loaders/studio/studioWorkerLoader.worker.d.ts +1 -0
  61. package/dist/loaders/studio/studioWorkerLoader.worker.js +117 -0
  62. package/dist/loaders/studio/studioWorkerLoader.worker.js.map +1 -0
  63. package/dist/loaders/studio/studioWorkerTask.d.ts +40 -0
  64. package/dist/loaders/studio/studioWorkerTask.js +69 -0
  65. package/dist/loaders/studio/studioWorkerTask.js.map +1 -0
  66. package/dist/loaders/tsx/tsxWorkerLoader.worker.d.ts +1 -0
  67. package/dist/loaders/tsx/tsxWorkerLoader.worker.js +12 -0
  68. package/dist/loaders/tsx/tsxWorkerLoader.worker.js.map +1 -0
  69. package/dist/loaders/tsx/tsxWorkerTask.d.ts +28 -0
  70. package/dist/loaders/tsx/tsxWorkerTask.js +61 -0
  71. package/dist/loaders/tsx/tsxWorkerTask.js.map +1 -0
  72. package/dist/services/apiClient.d.ts +39 -0
  73. package/dist/services/apiClient.js +88 -0
  74. package/dist/services/apiClient.js.map +1 -0
  75. package/dist/services/cliUserConfig.d.ts +57 -0
  76. package/dist/services/cliUserConfig.js +103 -0
  77. package/dist/services/cliUserConfig.js.map +1 -0
  78. package/dist/services/getCliToken.d.ts +7 -0
  79. package/dist/services/getCliToken.js +21 -0
  80. package/dist/services/getCliToken.js.map +1 -0
  81. package/dist/types.d.ts +7 -0
  82. package/dist/types.js +3 -0
  83. package/dist/types.js.map +1 -0
  84. package/dist/util/NotFoundError.d.ts +20 -0
  85. package/dist/util/NotFoundError.js +27 -0
  86. package/dist/util/NotFoundError.js.map +1 -0
  87. package/dist/util/__tests__/createExpiringConfig.test.js +309 -0
  88. package/dist/util/__tests__/createExpiringConfig.test.js.map +1 -0
  89. package/dist/util/createExpiringConfig.d.ts +32 -0
  90. package/dist/util/createExpiringConfig.js +35 -0
  91. package/dist/util/createExpiringConfig.js.map +1 -0
  92. package/dist/util/fileExists.d.ts +9 -0
  93. package/dist/util/fileExists.js +13 -0
  94. package/dist/util/fileExists.js.map +1 -0
  95. package/dist/util/generateHelpUrl.d.ts +8 -0
  96. package/dist/util/generateHelpUrl.js +11 -0
  97. package/dist/util/generateHelpUrl.js.map +1 -0
  98. package/dist/util/getSanityEnvVar.d.ts +19 -0
  99. package/dist/util/getSanityEnvVar.js +24 -0
  100. package/dist/util/getSanityEnvVar.js.map +1 -0
  101. package/dist/util/getSanityUrl.d.ts +5 -0
  102. package/dist/util/getSanityUrl.js +8 -0
  103. package/dist/util/getSanityUrl.js.map +1 -0
  104. package/dist/util/getUserConfig.d.ts +2 -0
  105. package/dist/util/getUserConfig.js +15 -0
  106. package/dist/util/getUserConfig.js.map +1 -0
  107. package/dist/util/isCi.d.ts +1 -0
  108. package/dist/util/isCi.js +7 -0
  109. package/dist/util/isCi.js.map +1 -0
  110. package/dist/util/isHttpError.d.ts +29 -0
  111. package/dist/util/isHttpError.js +18 -0
  112. package/dist/util/isHttpError.js.map +1 -0
  113. package/dist/util/isInteractive.d.ts +1 -0
  114. package/dist/util/isInteractive.js +5 -0
  115. package/dist/util/isInteractive.js.map +1 -0
  116. package/dist/util/isRecord.d.ts +8 -0
  117. package/dist/util/isRecord.js +11 -0
  118. package/dist/util/isRecord.js.map +1 -0
  119. package/dist/util/isTrueish.d.ts +1 -0
  120. package/dist/util/isTrueish.js +10 -0
  121. package/dist/util/isTrueish.js.map +1 -0
  122. package/dist/util/readJsonFile.d.ts +8 -0
  123. package/dist/util/readJsonFile.js +26 -0
  124. package/dist/util/readJsonFile.js.map +1 -0
  125. package/dist/util/safeStructuredClone.d.ts +8 -0
  126. package/dist/util/safeStructuredClone.js +40 -0
  127. package/dist/util/safeStructuredClone.js.map +1 -0
  128. package/dist/util/writeJsonFile.d.ts +9 -0
  129. package/dist/util/writeJsonFile.js +19 -0
  130. package/dist/util/writeJsonFile.js.map +1 -0
  131. package/dist/ux/colorizeJson.d.ts +1 -0
  132. package/dist/ux/colorizeJson.js +32 -0
  133. package/dist/ux/colorizeJson.js.map +1 -0
  134. package/dist/ux/formatObject.d.ts +1 -0
  135. package/dist/ux/formatObject.js +9 -0
  136. package/dist/ux/formatObject.js.map +1 -0
  137. package/dist/ux/logSymbols.d.ts +1 -0
  138. package/dist/ux/logSymbols.js +3 -0
  139. package/dist/ux/logSymbols.js.map +1 -0
  140. package/dist/ux/printKeyValue.d.ts +1 -0
  141. package/dist/ux/printKeyValue.js +16 -0
  142. package/dist/ux/printKeyValue.js.map +1 -0
  143. package/dist/ux/spinner.d.ts +1 -0
  144. package/dist/ux/spinner.js +3 -0
  145. package/dist/ux/spinner.js.map +1 -0
  146. package/dist/ux/timer.d.ts +12 -0
  147. package/dist/ux/timer.js +29 -0
  148. package/dist/ux/timer.js.map +1 -0
  149. package/package.json +81 -0
@@ -0,0 +1,190 @@
1
+ import { z } from 'zod';
2
+ declare const rawConfigSchema: z.ZodUnion<[z.ZodArray<z.ZodObject<{
3
+ basePath: z.ZodString;
4
+ dataset: z.ZodString;
5
+ name: z.ZodString;
6
+ plugins: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
7
+ projectId: z.ZodString;
8
+ schema: z.ZodObject<{
9
+ _original: z.ZodObject<{
10
+ name: z.ZodOptional<z.ZodString>;
11
+ types: z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">;
12
+ }, "strip", z.ZodTypeAny, {
13
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
14
+ name?: string | undefined;
15
+ }, {
16
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
17
+ name?: string | undefined;
18
+ }>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ _original: {
21
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
22
+ name?: string | undefined;
23
+ };
24
+ }, {
25
+ _original: {
26
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
27
+ name?: string | undefined;
28
+ };
29
+ }>;
30
+ title: z.ZodString;
31
+ }, "strip", z.ZodTypeAny, {
32
+ name: string;
33
+ dataset: string;
34
+ projectId: string;
35
+ basePath: string;
36
+ schema: {
37
+ _original: {
38
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
39
+ name?: string | undefined;
40
+ };
41
+ };
42
+ title: string;
43
+ plugins?: unknown[] | undefined;
44
+ }, {
45
+ name: string;
46
+ dataset: string;
47
+ projectId: string;
48
+ basePath: string;
49
+ schema: {
50
+ _original: {
51
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
52
+ name?: string | undefined;
53
+ };
54
+ };
55
+ title: string;
56
+ plugins?: unknown[] | undefined;
57
+ }>, "many">, z.ZodObject<{
58
+ basePath: z.ZodOptional<z.ZodString>;
59
+ dataset: z.ZodString;
60
+ name: z.ZodOptional<z.ZodString>;
61
+ plugins: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
62
+ projectId: z.ZodString;
63
+ schema: z.ZodOptional<z.ZodObject<{
64
+ name: z.ZodOptional<z.ZodString>;
65
+ types: z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">;
66
+ }, "strip", z.ZodTypeAny, {
67
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
68
+ name?: string | undefined;
69
+ }, {
70
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
71
+ name?: string | undefined;
72
+ }>>;
73
+ title: z.ZodOptional<z.ZodString>;
74
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
75
+ basePath: z.ZodOptional<z.ZodString>;
76
+ dataset: z.ZodString;
77
+ name: z.ZodOptional<z.ZodString>;
78
+ plugins: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
79
+ projectId: z.ZodString;
80
+ schema: z.ZodOptional<z.ZodObject<{
81
+ name: z.ZodOptional<z.ZodString>;
82
+ types: z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">;
83
+ }, "strip", z.ZodTypeAny, {
84
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
85
+ name?: string | undefined;
86
+ }, {
87
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
88
+ name?: string | undefined;
89
+ }>>;
90
+ title: z.ZodOptional<z.ZodString>;
91
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
92
+ basePath: z.ZodOptional<z.ZodString>;
93
+ dataset: z.ZodString;
94
+ name: z.ZodOptional<z.ZodString>;
95
+ plugins: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
96
+ projectId: z.ZodString;
97
+ schema: z.ZodOptional<z.ZodObject<{
98
+ name: z.ZodOptional<z.ZodString>;
99
+ types: z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">;
100
+ }, "strip", z.ZodTypeAny, {
101
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
102
+ name?: string | undefined;
103
+ }, {
104
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
105
+ name?: string | undefined;
106
+ }>>;
107
+ title: z.ZodOptional<z.ZodString>;
108
+ }, z.ZodTypeAny, "passthrough">>]>;
109
+ declare const resolvedConfigSchema: z.ZodArray<z.ZodObject<{
110
+ basePath: z.ZodString;
111
+ dataset: z.ZodString;
112
+ name: z.ZodString;
113
+ plugins: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
114
+ projectId: z.ZodString;
115
+ schema: z.ZodObject<{
116
+ _original: z.ZodObject<{
117
+ name: z.ZodOptional<z.ZodString>;
118
+ types: z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">;
119
+ }, "strip", z.ZodTypeAny, {
120
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
121
+ name?: string | undefined;
122
+ }, {
123
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
124
+ name?: string | undefined;
125
+ }>;
126
+ }, "strip", z.ZodTypeAny, {
127
+ _original: {
128
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
129
+ name?: string | undefined;
130
+ };
131
+ }, {
132
+ _original: {
133
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
134
+ name?: string | undefined;
135
+ };
136
+ }>;
137
+ title: z.ZodString;
138
+ }, "strip", z.ZodTypeAny, {
139
+ name: string;
140
+ dataset: string;
141
+ projectId: string;
142
+ basePath: string;
143
+ schema: {
144
+ _original: {
145
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
146
+ name?: string | undefined;
147
+ };
148
+ };
149
+ title: string;
150
+ plugins?: unknown[] | undefined;
151
+ }, {
152
+ name: string;
153
+ dataset: string;
154
+ projectId: string;
155
+ basePath: string;
156
+ schema: {
157
+ _original: {
158
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
159
+ name?: string | undefined;
160
+ };
161
+ };
162
+ title: string;
163
+ plugins?: unknown[] | undefined;
164
+ }>, "many">;
165
+ export type RawStudioConfig = z.infer<typeof rawConfigSchema>;
166
+ export type ResolvedStudioConfig = z.infer<typeof resolvedConfigSchema>;
167
+ export interface ReadStudioConfigOptions {
168
+ /**
169
+ * Whether or not to resolve the plugins defined in the config.
170
+ *
171
+ * In some cases, you need this in order to have the full picture of what the studio
172
+ * would "see". As an example, plugins can define schema types that are not explicitly
173
+ * defined in the users' schema types. In order to get the full picture, you need to
174
+ * resolve the plugins, which is an asyncronous operation.
175
+ *
176
+ * In other cases, it might be enough to only do a shallow pass. As an example, if you
177
+ * only need to know about the defined workspace, or the user-defined schema types,
178
+ * this can be set to `false` - which should resolve faster (and potentially "safer")
179
+ * in terms of not triggering all kinds of browser behavior that may or may not be
180
+ * loaded as the plugins are resolved.
181
+ */
182
+ resolvePlugins: boolean;
183
+ }
184
+ export declare function readStudioConfig(configPath: string, options: {
185
+ resolvePlugins: true;
186
+ }): Promise<ResolvedStudioConfig>;
187
+ export declare function readStudioConfig(configPath: string, options: {
188
+ resolvePlugins: false;
189
+ }): Promise<RawStudioConfig>;
190
+ export {};
@@ -0,0 +1,45 @@
1
+ import { dirname } from 'node:path';
2
+ import { z } from 'zod';
3
+ import { studioWorkerTask } from '../../loaders/studio/studioWorkerTask.js';
4
+ const schemaSchema = z.object({
5
+ name: z.string().optional(),
6
+ types: z.array(z.object({}).passthrough())
7
+ });
8
+ const singleStudioWorkspaceSchema = z.object({
9
+ basePath: z.string().optional(),
10
+ dataset: z.string(),
11
+ name: z.string().optional(),
12
+ plugins: z.array(z.unknown()).optional(),
13
+ projectId: z.string(),
14
+ schema: schemaSchema.optional(),
15
+ title: z.string().optional()
16
+ }).passthrough();
17
+ const studioWorkspaceSchema = z.object({
18
+ basePath: z.string(),
19
+ dataset: z.string(),
20
+ name: z.string(),
21
+ plugins: z.array(z.unknown()).optional(),
22
+ projectId: z.string(),
23
+ schema: z.object({
24
+ _original: schemaSchema
25
+ }),
26
+ title: z.string()
27
+ });
28
+ const rawConfigSchema = z.union([
29
+ z.array(studioWorkspaceSchema),
30
+ singleStudioWorkspaceSchema
31
+ ]);
32
+ const resolvedConfigSchema = z.array(studioWorkspaceSchema);
33
+ export async function readStudioConfig(configPath, options) {
34
+ const result = await studioWorkerTask(new URL('readStudioConfig.worker.js', import.meta.url), {
35
+ name: 'studioConfig',
36
+ studioRootPath: dirname(configPath),
37
+ workerData: {
38
+ configPath,
39
+ resolvePlugins: options.resolvePlugins
40
+ }
41
+ });
42
+ return options.resolvePlugins ? resolvedConfigSchema.parse(result) : rawConfigSchema.parse(result);
43
+ }
44
+
45
+ //# sourceMappingURL=readStudioConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/config/studio/readStudioConfig.ts"],"sourcesContent":["import {dirname} from 'node:path'\n\nimport {z} from 'zod'\n\nimport {studioWorkerTask} from '../../loaders/studio/studioWorkerTask.js'\n\nconst schemaSchema = z.object({\n name: z.string().optional(),\n types: z.array(z.object({}).passthrough()),\n})\n\nconst singleStudioWorkspaceSchema = z\n .object({\n basePath: z.string().optional(),\n dataset: z.string(),\n name: z.string().optional(),\n plugins: z.array(z.unknown()).optional(),\n projectId: z.string(),\n schema: schemaSchema.optional(),\n title: z.string().optional(),\n })\n .passthrough()\n\nconst studioWorkspaceSchema = z.object({\n basePath: z.string(),\n dataset: z.string(),\n name: z.string(),\n plugins: z.array(z.unknown()).optional(),\n projectId: z.string(),\n schema: z.object({_original: schemaSchema}),\n title: z.string(),\n})\n\nconst rawConfigSchema = z.union([z.array(studioWorkspaceSchema), singleStudioWorkspaceSchema])\nconst resolvedConfigSchema = z.array(studioWorkspaceSchema)\n\nexport type RawStudioConfig = z.infer<typeof rawConfigSchema>\nexport type ResolvedStudioConfig = z.infer<typeof resolvedConfigSchema>\n\nexport interface ReadStudioConfigOptions {\n /**\n * Whether or not to resolve the plugins defined in the config.\n *\n * In some cases, you need this in order to have the full picture of what the studio\n * would \"see\". As an example, plugins can define schema types that are not explicitly\n * defined in the users' schema types. In order to get the full picture, you need to\n * resolve the plugins, which is an asyncronous operation.\n *\n * In other cases, it might be enough to only do a shallow pass. As an example, if you\n * only need to know about the defined workspace, or the user-defined schema types,\n * this can be set to `false` - which should resolve faster (and potentially \"safer\")\n * in terms of not triggering all kinds of browser behavior that may or may not be\n * loaded as the plugins are resolved.\n */\n resolvePlugins: boolean\n}\n\nexport async function readStudioConfig(\n configPath: string,\n options: {resolvePlugins: true},\n): Promise<ResolvedStudioConfig>\n\nexport async function readStudioConfig(\n configPath: string,\n options: {resolvePlugins: false},\n): Promise<RawStudioConfig>\n\nexport async function readStudioConfig(\n configPath: string,\n options: ReadStudioConfigOptions,\n): Promise<RawStudioConfig | ResolvedStudioConfig> {\n const result = await studioWorkerTask(new URL('readStudioConfig.worker.js', import.meta.url), {\n name: 'studioConfig',\n studioRootPath: dirname(configPath),\n workerData: {configPath, resolvePlugins: options.resolvePlugins},\n })\n\n return options.resolvePlugins ? resolvedConfigSchema.parse(result) : rawConfigSchema.parse(result)\n}\n"],"names":["dirname","z","studioWorkerTask","schemaSchema","object","name","string","optional","types","array","passthrough","singleStudioWorkspaceSchema","basePath","dataset","plugins","unknown","projectId","schema","title","studioWorkspaceSchema","_original","rawConfigSchema","union","resolvedConfigSchema","readStudioConfig","configPath","options","result","URL","url","studioRootPath","workerData","resolvePlugins","parse"],"mappings":"AAAA,SAAQA,OAAO,QAAO,YAAW;AAEjC,SAAQC,CAAC,QAAO,MAAK;AAErB,SAAQC,gBAAgB,QAAO,2CAA0C;AAEzE,MAAMC,eAAeF,EAAEG,MAAM,CAAC;IAC5BC,MAAMJ,EAAEK,MAAM,GAAGC,QAAQ;IACzBC,OAAOP,EAAEQ,KAAK,CAACR,EAAEG,MAAM,CAAC,CAAC,GAAGM,WAAW;AACzC;AAEA,MAAMC,8BAA8BV,EACjCG,MAAM,CAAC;IACNQ,UAAUX,EAAEK,MAAM,GAAGC,QAAQ;IAC7BM,SAASZ,EAAEK,MAAM;IACjBD,MAAMJ,EAAEK,MAAM,GAAGC,QAAQ;IACzBO,SAASb,EAAEQ,KAAK,CAACR,EAAEc,OAAO,IAAIR,QAAQ;IACtCS,WAAWf,EAAEK,MAAM;IACnBW,QAAQd,aAAaI,QAAQ;IAC7BW,OAAOjB,EAAEK,MAAM,GAAGC,QAAQ;AAC5B,GACCG,WAAW;AAEd,MAAMS,wBAAwBlB,EAAEG,MAAM,CAAC;IACrCQ,UAAUX,EAAEK,MAAM;IAClBO,SAASZ,EAAEK,MAAM;IACjBD,MAAMJ,EAAEK,MAAM;IACdQ,SAASb,EAAEQ,KAAK,CAACR,EAAEc,OAAO,IAAIR,QAAQ;IACtCS,WAAWf,EAAEK,MAAM;IACnBW,QAAQhB,EAAEG,MAAM,CAAC;QAACgB,WAAWjB;IAAY;IACzCe,OAAOjB,EAAEK,MAAM;AACjB;AAEA,MAAMe,kBAAkBpB,EAAEqB,KAAK,CAAC;IAACrB,EAAEQ,KAAK,CAACU;IAAwBR;CAA4B;AAC7F,MAAMY,uBAAuBtB,EAAEQ,KAAK,CAACU;AAiCrC,OAAO,eAAeK,iBACpBC,UAAkB,EAClBC,OAAgC;IAEhC,MAAMC,SAAS,MAAMzB,iBAAiB,IAAI0B,IAAI,8BAA8B,YAAYC,GAAG,GAAG;QAC5FxB,MAAM;QACNyB,gBAAgB9B,QAAQyB;QACxBM,YAAY;YAACN;YAAYO,gBAAgBN,QAAQM,cAAc;QAAA;IACjE;IAEA,OAAON,QAAQM,cAAc,GAAGT,qBAAqBU,KAAK,CAACN,UAAUN,gBAAgBY,KAAK,CAACN;AAC7F"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,64 @@
1
+ import { pathToFileURL } from 'node:url';
2
+ import { isMainThread, parentPort, workerData } from 'node:worker_threads';
3
+ import { createClient } from '@sanity/client';
4
+ import { moduleResolve } from 'import-meta-resolve';
5
+ import { z } from 'zod';
6
+ import { safeStructuredClone } from '../../util/safeStructuredClone.js';
7
+ if (isMainThread || !parentPort) {
8
+ throw new Error('Should only be run in a worker!');
9
+ }
10
+ const EMPTY_AUTH_STATE = {
11
+ authenticated: false,
12
+ client: getDummyClient(),
13
+ currentUser: null
14
+ };
15
+ const { configPath, resolvePlugins } = z.object({
16
+ configPath: z.string(),
17
+ resolvePlugins: z.boolean()
18
+ }).parse(workerData);
19
+ let { default: config } = await import(configPath);
20
+ if (resolvePlugins) {
21
+ // If we need to resolve plugins, we need to import and use the `resolveConfig`
22
+ // function from the `sanity` package. This package should be installed in the users'
23
+ // studio project, not as part of the CLI - so we need to resolve the full path of the
24
+ // Sanity package relative to the studio.
25
+ const configUrl = pathToFileURL(configPath);
26
+ const sanityUrl = await moduleResolve('sanity', configUrl);
27
+ const { resolveConfig } = await import(sanityUrl.href);
28
+ if (typeof resolveConfig !== 'function') {
29
+ throw new TypeError('Expected `resolveConfig` from `sanity` to be a function');
30
+ }
31
+ // We'll want to use some observable tooling, but we'd prefer to use something
32
+ // compatible with what the studio uses internally, thus try to load RxJS from the
33
+ // sanity module path instead of installing it as a dependency locally.
34
+ const rxjsPath = (await moduleResolve('rxjs', sanityUrl)).href;
35
+ const { firstValueFrom, of } = await import(rxjsPath);
36
+ // We will also want to stub out some configuration - we don't need to resolve the
37
+ // users' logged in state, for instance - so let's disable the auth implementation.
38
+ const workspaces = Array.isArray(config) ? config : [
39
+ config
40
+ ];
41
+ workspaces.map((workspace)=>{
42
+ workspace.auth = {
43
+ state: of(EMPTY_AUTH_STATE)
44
+ };
45
+ });
46
+ config = await firstValueFrom(resolveConfig(config));
47
+ }
48
+ parentPort.postMessage(safeStructuredClone(config));
49
+ // Explicitly exit the process to avoid any dangling references from keeping
50
+ // the process alive after resolving it's main task
51
+ setImmediate(()=>{
52
+ process.exit(1);
53
+ });
54
+ function getDummyClient() {
55
+ return createClient({
56
+ apiHost: 'http://localhost',
57
+ apiVersion: '2025-02-01',
58
+ projectId: 'unused',
59
+ requestTagPrefix: 'sanity.cli',
60
+ useCdn: false
61
+ });
62
+ }
63
+
64
+ //# sourceMappingURL=readStudioConfig.worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/config/studio/readStudioConfig.worker.ts"],"sourcesContent":["import {pathToFileURL} from 'node:url'\nimport {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {createClient} from '@sanity/client'\nimport {moduleResolve} from 'import-meta-resolve'\nimport {z} from 'zod'\n\nimport {safeStructuredClone} from '../../util/safeStructuredClone.js'\n\nif (isMainThread || !parentPort) {\n throw new Error('Should only be run in a worker!')\n}\n\nconst EMPTY_AUTH_STATE = {\n authenticated: false,\n client: getDummyClient(),\n currentUser: null,\n}\n\nconst {configPath, resolvePlugins} = z\n .object({configPath: z.string(), resolvePlugins: z.boolean()})\n .parse(workerData)\n\nlet {default: config} = await import(configPath)\n\nif (resolvePlugins) {\n // If we need to resolve plugins, we need to import and use the `resolveConfig`\n // function from the `sanity` package. This package should be installed in the users'\n // studio project, not as part of the CLI - so we need to resolve the full path of the\n // Sanity package relative to the studio.\n const configUrl = pathToFileURL(configPath)\n\n const sanityUrl = await moduleResolve('sanity', configUrl)\n const {resolveConfig} = await import(sanityUrl.href)\n if (typeof resolveConfig !== 'function') {\n throw new TypeError('Expected `resolveConfig` from `sanity` to be a function')\n }\n\n // We'll want to use some observable tooling, but we'd prefer to use something\n // compatible with what the studio uses internally, thus try to load RxJS from the\n // sanity module path instead of installing it as a dependency locally.\n const rxjsPath = (await moduleResolve('rxjs', sanityUrl)).href\n const {firstValueFrom, of} = await import(rxjsPath)\n\n // We will also want to stub out some configuration - we don't need to resolve the\n // users' logged in state, for instance - so let's disable the auth implementation.\n const workspaces = Array.isArray(config) ? config : [config]\n workspaces.map((workspace) => {\n workspace.auth = {state: of(EMPTY_AUTH_STATE)}\n })\n\n config = await firstValueFrom(resolveConfig(config))\n}\n\nparentPort.postMessage(safeStructuredClone(config))\n\n// Explicitly exit the process to avoid any dangling references from keeping\n// the process alive after resolving it's main task\nsetImmediate(() => {\n process.exit(1)\n})\n\nfunction getDummyClient() {\n return createClient({\n apiHost: 'http://localhost',\n apiVersion: '2025-02-01',\n projectId: 'unused',\n requestTagPrefix: 'sanity.cli',\n useCdn: false,\n })\n}\n"],"names":["pathToFileURL","isMainThread","parentPort","workerData","createClient","moduleResolve","z","safeStructuredClone","Error","EMPTY_AUTH_STATE","authenticated","client","getDummyClient","currentUser","configPath","resolvePlugins","object","string","boolean","parse","default","config","configUrl","sanityUrl","resolveConfig","href","TypeError","rxjsPath","firstValueFrom","of","workspaces","Array","isArray","map","workspace","auth","state","postMessage","setImmediate","process","exit","apiHost","apiVersion","projectId","requestTagPrefix","useCdn"],"mappings":"AAAA,SAAQA,aAAa,QAAO,WAAU;AACtC,SAAQC,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,YAAY,QAAO,iBAAgB;AAC3C,SAAQC,aAAa,QAAO,sBAAqB;AACjD,SAAQC,CAAC,QAAO,MAAK;AAErB,SAAQC,mBAAmB,QAAO,oCAAmC;AAErE,IAAIN,gBAAgB,CAACC,YAAY;IAC/B,MAAM,IAAIM,MAAM;AAClB;AAEA,MAAMC,mBAAmB;IACvBC,eAAe;IACfC,QAAQC;IACRC,aAAa;AACf;AAEA,MAAM,EAACC,UAAU,EAAEC,cAAc,EAAC,GAAGT,EAClCU,MAAM,CAAC;IAACF,YAAYR,EAAEW,MAAM;IAAIF,gBAAgBT,EAAEY,OAAO;AAAE,GAC3DC,KAAK,CAAChB;AAET,IAAI,EAACiB,SAASC,MAAM,EAAC,GAAG,MAAM,MAAM,CAACP;AAErC,IAAIC,gBAAgB;IAClB,+EAA+E;IAC/E,qFAAqF;IACrF,sFAAsF;IACtF,yCAAyC;IACzC,MAAMO,YAAYtB,cAAcc;IAEhC,MAAMS,YAAY,MAAMlB,cAAc,UAAUiB;IAChD,MAAM,EAACE,aAAa,EAAC,GAAG,MAAM,MAAM,CAACD,UAAUE,IAAI;IACnD,IAAI,OAAOD,kBAAkB,YAAY;QACvC,MAAM,IAAIE,UAAU;IACtB;IAEA,8EAA8E;IAC9E,kFAAkF;IAClF,uEAAuE;IACvE,MAAMC,WAAW,AAAC,CAAA,MAAMtB,cAAc,QAAQkB,UAAS,EAAGE,IAAI;IAC9D,MAAM,EAACG,cAAc,EAAEC,EAAE,EAAC,GAAG,MAAM,MAAM,CAACF;IAE1C,kFAAkF;IAClF,mFAAmF;IACnF,MAAMG,aAAaC,MAAMC,OAAO,CAACX,UAAUA,SAAS;QAACA;KAAO;IAC5DS,WAAWG,GAAG,CAAC,CAACC;QACdA,UAAUC,IAAI,GAAG;YAACC,OAAOP,GAAGpB;QAAiB;IAC/C;IAEAY,SAAS,MAAMO,eAAeJ,cAAcH;AAC9C;AAEAnB,WAAWmC,WAAW,CAAC9B,oBAAoBc;AAE3C,4EAA4E;AAC5E,mDAAmD;AACnDiB,aAAa;IACXC,QAAQC,IAAI,CAAC;AACf;AAEA,SAAS5B;IACP,OAAOR,aAAa;QAClBqC,SAAS;QACTC,YAAY;QACZC,WAAW;QACXC,kBAAkB;QAClBC,QAAQ;IACV;AACF"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Resolves to a string containing the found config path, or `undefined` if not found.
3
+ *
4
+ * @param basePath - The base path to start searching from
5
+ * @returns A promise that resolves to a string containing the found config path, or `undefined` if not found
6
+ * @internal
7
+ */
8
+ export declare function findAppConfigPath(basePath: string): Promise<string | undefined>;
@@ -0,0 +1,22 @@
1
+ import { findPathForFiles } from './findConfigsPaths.js';
2
+ /**
3
+ * Resolves to a string containing the found config path, or `undefined` if not found.
4
+ *
5
+ * @param basePath - The base path to start searching from
6
+ * @returns A promise that resolves to a string containing the found config path, or `undefined` if not found
7
+ * @internal
8
+ */ export async function findAppConfigPath(basePath) {
9
+ const paths = await findPathForFiles(basePath, [
10
+ 'sanity.cli.ts',
11
+ 'sanity.cli.js'
12
+ ]);
13
+ const configPaths = paths.filter((path)=>path.exists);
14
+ if (configPaths.length > 1) {
15
+ throw new Error(`Multiple app config files found (${configPaths.map((path)=>path.path).join(', ')})`);
16
+ }
17
+ if (configPaths.length === 1) {
18
+ return configPaths[0].path;
19
+ }
20
+ }
21
+
22
+ //# sourceMappingURL=findAppConfigPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/config/util/findAppConfigPath.ts"],"sourcesContent":["import {findPathForFiles} from './findConfigsPaths.js'\n\n/**\n * Resolves to a string containing the found config path, or `undefined` if not found.\n *\n * @param basePath - The base path to start searching from\n * @returns A promise that resolves to a string containing the found config path, or `undefined` if not found\n * @internal\n */\nexport async function findAppConfigPath(basePath: string): Promise<string | undefined> {\n const paths = await findPathForFiles(basePath, ['sanity.cli.ts', 'sanity.cli.js'])\n const configPaths = paths.filter((path) => path.exists)\n if (configPaths.length > 1) {\n throw new Error(\n `Multiple app config files found (${configPaths.map((path) => path.path).join(', ')})`,\n )\n }\n\n if (configPaths.length === 1) {\n return configPaths[0].path\n }\n}\n"],"names":["findPathForFiles","findAppConfigPath","basePath","paths","configPaths","filter","path","exists","length","Error","map","join"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,wBAAuB;AAEtD;;;;;;CAMC,GACD,OAAO,eAAeC,kBAAkBC,QAAgB;IACtD,MAAMC,QAAQ,MAAMH,iBAAiBE,UAAU;QAAC;QAAiB;KAAgB;IACjF,MAAME,cAAcD,MAAME,MAAM,CAAC,CAACC,OAASA,KAAKC,MAAM;IACtD,IAAIH,YAAYI,MAAM,GAAG,GAAG;QAC1B,MAAM,IAAIC,MACR,CAAC,iCAAiC,EAAEL,YAAYM,GAAG,CAAC,CAACJ,OAASA,KAAKA,IAAI,EAAEK,IAAI,CAAC,MAAM,CAAC,CAAC;IAE1F;IAEA,IAAIP,YAAYI,MAAM,KAAK,GAAG;QAC5B,OAAOJ,WAAW,CAAC,EAAE,CAACE,IAAI;IAC5B;AACF"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ interface PathResult {
5
+ exists: boolean;
6
+ path: string;
7
+ }
8
+ /**
9
+ * Finds the path for a given set of files.
10
+ *
11
+ * @param basePath - The base path to search for files.
12
+ * @param files - The files to search for.
13
+ * @internal
14
+ */
15
+ export declare function findPathForFiles(basePath: string, files: string[]): Promise<PathResult[]>;
16
+ export {};
@@ -0,0 +1,21 @@
1
+ import { join } from 'node:path';
2
+ import { fileExists } from '../../util/fileExists.js';
3
+ /**
4
+ * Finds the path for a given set of files.
5
+ *
6
+ * @param basePath - The base path to search for files.
7
+ * @param files - The files to search for.
8
+ * @internal
9
+ */ export async function findPathForFiles(basePath, files) {
10
+ const paths = await Promise.all(files.map(async (file)=>{
11
+ const path = join(basePath, file);
12
+ const exists = await fileExists(path);
13
+ return {
14
+ exists,
15
+ path
16
+ };
17
+ }));
18
+ return paths;
19
+ }
20
+
21
+ //# sourceMappingURL=findConfigsPaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/config/util/findConfigsPaths.ts"],"sourcesContent":["import {join} from 'node:path'\n\nimport {fileExists} from '../../util/fileExists.js'\n\n/**\n * @internal\n */\ninterface PathResult {\n exists: boolean\n path: string\n}\n\n/**\n * Finds the path for a given set of files.\n *\n * @param basePath - The base path to search for files.\n * @param files - The files to search for.\n * @internal\n */\nexport async function findPathForFiles(basePath: string, files: string[]): Promise<PathResult[]> {\n const paths = await Promise.all(\n files.map(async (file) => {\n const path = join(basePath, file)\n const exists = await fileExists(path)\n return {exists, path}\n }),\n )\n\n return paths\n}\n"],"names":["join","fileExists","findPathForFiles","basePath","files","paths","Promise","all","map","file","path","exists"],"mappings":"AAAA,SAAQA,IAAI,QAAO,YAAW;AAE9B,SAAQC,UAAU,QAAO,2BAA0B;AAUnD;;;;;;CAMC,GACD,OAAO,eAAeC,iBAAiBC,QAAgB,EAAEC,KAAe;IACtE,MAAMC,QAAQ,MAAMC,QAAQC,GAAG,CAC7BH,MAAMI,GAAG,CAAC,OAAOC;QACf,MAAMC,OAAOV,KAAKG,UAAUM;QAC5B,MAAME,SAAS,MAAMV,WAAWS;QAChC,OAAO;YAACC;YAAQD;QAAI;IACtB;IAGF,OAAOL;AACT"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Resolves to a string containing the found config path, or `false` if not found.
3
+ * Throws if Sanity v2 studio root is found.
4
+ *
5
+ * @param basePath - The base path to start searching from
6
+ * @returns A promise that resolves to a string containing the found config path, or `undefined` if not found
7
+ * @internal
8
+ */
9
+ export declare function findStudioConfigPath(basePath: string): Promise<string | undefined>;
@@ -0,0 +1,31 @@
1
+ import { basename } from 'node:path';
2
+ import { findPathForFiles } from './findConfigsPaths.js';
3
+ import { isSanityV2StudioRoot } from './isSanityV2StudioRoot.js';
4
+ /**
5
+ * Resolves to a string containing the found config path, or `false` if not found.
6
+ * Throws if Sanity v2 studio root is found.
7
+ *
8
+ * @param basePath - The base path to start searching from
9
+ * @returns A promise that resolves to a string containing the found config path, or `undefined` if not found
10
+ * @internal
11
+ */ export async function findStudioConfigPath(basePath) {
12
+ if (await isSanityV2StudioRoot(basePath)) {
13
+ throw new Error(`Found 'sanity.json' at ${basePath} - Sanity Studio < v3 is no longer supported`);
14
+ }
15
+ const paths = await findPathForFiles(basePath, [
16
+ 'sanity.config.ts',
17
+ 'sanity.config.tsx',
18
+ 'sanity.config.js',
19
+ 'sanity.config.jsx'
20
+ ]);
21
+ const configPaths = paths.filter((path)=>path.exists);
22
+ if (configPaths.length > 1) {
23
+ const baseNames = configPaths.map((config)=>config.path).map((path)=>basename(path));
24
+ throw new Error(`Multiple studio config files found (${baseNames.join(', ')})`);
25
+ }
26
+ if (configPaths.length === 1) {
27
+ return configPaths[0].path;
28
+ }
29
+ }
30
+
31
+ //# sourceMappingURL=findStudioConfigPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/config/util/findStudioConfigPath.ts"],"sourcesContent":["import {basename} from 'node:path'\n\nimport {findPathForFiles} from './findConfigsPaths.js'\nimport {isSanityV2StudioRoot} from './isSanityV2StudioRoot.js'\n\n/**\n * Resolves to a string containing the found config path, or `false` if not found.\n * Throws if Sanity v2 studio root is found.\n *\n * @param basePath - The base path to start searching from\n * @returns A promise that resolves to a string containing the found config path, or `undefined` if not found\n * @internal\n */\nexport async function findStudioConfigPath(basePath: string): Promise<string | undefined> {\n if (await isSanityV2StudioRoot(basePath)) {\n throw new Error(\n `Found 'sanity.json' at ${basePath} - Sanity Studio < v3 is no longer supported`,\n )\n }\n\n const paths = await findPathForFiles(basePath, [\n 'sanity.config.ts',\n 'sanity.config.tsx',\n 'sanity.config.js',\n 'sanity.config.jsx',\n ])\n\n const configPaths = paths.filter((path) => path.exists)\n if (configPaths.length > 1) {\n const baseNames = configPaths.map((config) => config.path).map((path) => basename(path))\n throw new Error(`Multiple studio config files found (${baseNames.join(', ')})`)\n }\n\n if (configPaths.length === 1) {\n return configPaths[0].path\n }\n}\n"],"names":["basename","findPathForFiles","isSanityV2StudioRoot","findStudioConfigPath","basePath","Error","paths","configPaths","filter","path","exists","length","baseNames","map","config","join"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,YAAW;AAElC,SAAQC,gBAAgB,QAAO,wBAAuB;AACtD,SAAQC,oBAAoB,QAAO,4BAA2B;AAE9D;;;;;;;CAOC,GACD,OAAO,eAAeC,qBAAqBC,QAAgB;IACzD,IAAI,MAAMF,qBAAqBE,WAAW;QACxC,MAAM,IAAIC,MACR,CAAC,uBAAuB,EAAED,SAAS,4CAA4C,CAAC;IAEpF;IAEA,MAAME,QAAQ,MAAML,iBAAiBG,UAAU;QAC7C;QACA;QACA;QACA;KACD;IAED,MAAMG,cAAcD,MAAME,MAAM,CAAC,CAACC,OAASA,KAAKC,MAAM;IACtD,IAAIH,YAAYI,MAAM,GAAG,GAAG;QAC1B,MAAMC,YAAYL,YAAYM,GAAG,CAAC,CAACC,SAAWA,OAAOL,IAAI,EAAEI,GAAG,CAAC,CAACJ,OAAST,SAASS;QAClF,MAAM,IAAIJ,MAAM,CAAC,oCAAoC,EAAEO,UAAUG,IAAI,CAAC,MAAM,CAAC,CAAC;IAChF;IAEA,IAAIR,YAAYI,MAAM,KAAK,GAAG;QAC5B,OAAOJ,WAAW,CAAC,EAAE,CAACE,IAAI;IAC5B;AACF"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks for a `sanity.json` file with `"root": true` in the given directory.
3
+ *
4
+ * @param basePath - The base path to look for a `sanity.json` in
5
+ * @returns Resolves to true if a `sanity.json` with `"root": true` is found, false otherwise
6
+ * @internal
7
+ */
8
+ export declare function isSanityV2StudioRoot(basePath: string): Promise<boolean>;
@@ -0,0 +1,19 @@
1
+ import { join } from 'node:path';
2
+ import { readJsonFile } from '../../util/readJsonFile.js';
3
+ /**
4
+ * Checks for a `sanity.json` file with `"root": true` in the given directory.
5
+ *
6
+ * @param basePath - The base path to look for a `sanity.json` in
7
+ * @returns Resolves to true if a `sanity.json` with `"root": true` is found, false otherwise
8
+ * @internal
9
+ */ export async function isSanityV2StudioRoot(basePath) {
10
+ try {
11
+ const sanityJson = await readJsonFile(join(basePath, 'sanity.json'));
12
+ const isRoot = Boolean(sanityJson?.root);
13
+ return isRoot;
14
+ } catch {
15
+ return false;
16
+ }
17
+ }
18
+
19
+ //# sourceMappingURL=isSanityV2StudioRoot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/config/util/isSanityV2StudioRoot.ts"],"sourcesContent":["import {join} from 'node:path'\n\nimport {readJsonFile} from '../../util/readJsonFile.js'\n\n/**\n * Checks for a `sanity.json` file with `\"root\": true` in the given directory.\n *\n * @param basePath - The base path to look for a `sanity.json` in\n * @returns Resolves to true if a `sanity.json` with `\"root\": true` is found, false otherwise\n * @internal\n */\nexport async function isSanityV2StudioRoot(basePath: string): Promise<boolean> {\n try {\n const sanityJson = await readJsonFile(join(basePath, 'sanity.json'))\n const isRoot = Boolean(sanityJson?.root)\n return isRoot\n } catch {\n return false\n }\n}\n"],"names":["join","readJsonFile","isSanityV2StudioRoot","basePath","sanityJson","isRoot","Boolean","root"],"mappings":"AAAA,SAAQA,IAAI,QAAO,YAAW;AAE9B,SAAQC,YAAY,QAAO,6BAA4B;AAEvD;;;;;;CAMC,GACD,OAAO,eAAeC,qBAAqBC,QAAgB;IACzD,IAAI;QACF,MAAMC,aAAa,MAAMH,aAAaD,KAAKG,UAAU;QACrD,MAAME,SAASC,QAAQF,YAAYG;QACnC,OAAOF;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Result of finding a project configuration
3
+ *
4
+ * @internal
5
+ */
6
+ export interface ProjectRootResult {
7
+ directory: string;
8
+ /**
9
+ * Path to the project configuration file, if found.
10
+ */
11
+ path: string;
12
+ /**
13
+ * Type of project root.
14
+ */
15
+ type: 'app' | 'studio';
16
+ }
17
+ /**
18
+ * Generic recursive search function for project configuration files.
19
+ *
20
+ * @param basePath - The base path to start searching from
21
+ * @param findConfigFn - Function that looks for config files in a given directory
22
+ * @param projectType - The type of project ('app' | 'studio')
23
+ * @param iterations - Current iteration count, passed internally to prevent infinite recursion
24
+ * @returns A promise that resolves to an object if config is found, false otherwise
25
+ * @internal
26
+ */
27
+ export declare function recursivelyResolveProjectRoot(basePath: string, findConfigFn: (path: string) => Promise<string | undefined>, projectType: 'app' | 'studio', iterations?: number): Promise<false | ProjectRootResult>;
@@ -0,0 +1,28 @@
1
+ import { dirname, resolve } from 'node:path';
2
+ /**
3
+ * Generic recursive search function for project configuration files.
4
+ *
5
+ * @param basePath - The base path to start searching from
6
+ * @param findConfigFn - Function that looks for config files in a given directory
7
+ * @param projectType - The type of project ('app' | 'studio')
8
+ * @param iterations - Current iteration count, passed internally to prevent infinite recursion
9
+ * @returns A promise that resolves to an object if config is found, false otherwise
10
+ * @internal
11
+ */ export async function recursivelyResolveProjectRoot(basePath, findConfigFn, projectType, iterations = 0) {
12
+ const configPath = await findConfigFn(basePath);
13
+ if (configPath) {
14
+ return {
15
+ directory: dirname(configPath),
16
+ path: configPath,
17
+ type: projectType
18
+ };
19
+ }
20
+ const parentDir = resolve(basePath, '..');
21
+ if (parentDir === basePath || iterations > 50) {
22
+ // Reached root (or max depth), give up
23
+ return false;
24
+ }
25
+ return recursivelyResolveProjectRoot(parentDir, findConfigFn, projectType, iterations + 1);
26
+ }
27
+
28
+ //# sourceMappingURL=recursivelyResolveProjectRoot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/config/util/recursivelyResolveProjectRoot.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path'\n\n/**\n * Result of finding a project configuration\n *\n * @internal\n */\nexport interface ProjectRootResult {\n directory: string\n /**\n * Path to the project configuration file, if found.\n */\n path: string\n /**\n * Type of project root.\n */\n type: 'app' | 'studio'\n}\n\n/**\n * Generic recursive search function for project configuration files.\n *\n * @param basePath - The base path to start searching from\n * @param findConfigFn - Function that looks for config files in a given directory\n * @param projectType - The type of project ('app' | 'studio')\n * @param iterations - Current iteration count, passed internally to prevent infinite recursion\n * @returns A promise that resolves to an object if config is found, false otherwise\n * @internal\n */\nexport async function recursivelyResolveProjectRoot(\n basePath: string,\n findConfigFn: (path: string) => Promise<string | undefined>,\n projectType: 'app' | 'studio',\n iterations = 0,\n): Promise<false | ProjectRootResult> {\n const configPath = await findConfigFn(basePath)\n\n if (configPath) {\n return {\n directory: dirname(configPath),\n path: configPath,\n type: projectType,\n }\n }\n\n const parentDir = resolve(basePath, '..')\n if (parentDir === basePath || iterations > 50) {\n // Reached root (or max depth), give up\n return false\n }\n\n return recursivelyResolveProjectRoot(parentDir, findConfigFn, projectType, iterations + 1)\n}\n"],"names":["dirname","resolve","recursivelyResolveProjectRoot","basePath","findConfigFn","projectType","iterations","configPath","directory","path","type","parentDir"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,YAAW;AAmB1C;;;;;;;;;CASC,GACD,OAAO,eAAeC,8BACpBC,QAAgB,EAChBC,YAA2D,EAC3DC,WAA6B,EAC7BC,aAAa,CAAC;IAEd,MAAMC,aAAa,MAAMH,aAAaD;IAEtC,IAAII,YAAY;QACd,OAAO;YACLC,WAAWR,QAAQO;YACnBE,MAAMF;YACNG,MAAML;QACR;IACF;IAEA,MAAMM,YAAYV,QAAQE,UAAU;IACpC,IAAIQ,cAAcR,YAAYG,aAAa,IAAI;QAC7C,uCAAuC;QACvC,OAAO;IACT;IAEA,OAAOJ,8BAA8BS,WAAWP,cAAcC,aAAaC,aAAa;AAC1F"}
@@ -0,0 +1,15 @@
1
+ import debugIt from 'debug';
2
+ /**
3
+ * `debug` instance for the CLI
4
+ *
5
+ * @internal
6
+ */
7
+ export declare const debug: debugIt.Debugger;
8
+ /**
9
+ * Get a `debug` instance which extends the CLI debug instance with the given namespace,
10
+ * eg namespace would be `sanity:cli:<providedNamespace>`
11
+ *
12
+ * @param namespace - The namespace to extend the CLI debug instance with
13
+ * @returns The extended `debug` instance
14
+ */
15
+ export declare const subdebug: (namespace: string) => debugIt.Debugger;
package/dist/debug.js ADDED
@@ -0,0 +1,15 @@
1
+ import debugIt from 'debug';
2
+ /**
3
+ * `debug` instance for the CLI
4
+ *
5
+ * @internal
6
+ */ export const debug = debugIt('sanity:cli');
7
+ /**
8
+ * Get a `debug` instance which extends the CLI debug instance with the given namespace,
9
+ * eg namespace would be `sanity:cli:<providedNamespace>`
10
+ *
11
+ * @param namespace - The namespace to extend the CLI debug instance with
12
+ * @returns The extended `debug` instance
13
+ */ export const subdebug = (namespace)=>debug.extend(namespace);
14
+
15
+ //# sourceMappingURL=debug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/debug.ts"],"sourcesContent":["import debugIt from 'debug'\n\n/**\n * `debug` instance for the CLI\n *\n * @internal\n */\nexport const debug = debugIt('sanity:cli')\n\n/**\n * Get a `debug` instance which extends the CLI debug instance with the given namespace,\n * eg namespace would be `sanity:cli:<providedNamespace>`\n *\n * @param namespace - The namespace to extend the CLI debug instance with\n * @returns The extended `debug` instance\n */\nexport const subdebug = (namespace: string) => debug.extend(namespace)\n"],"names":["debugIt","debug","subdebug","namespace","extend"],"mappings":"AAAA,OAAOA,aAAa,QAAO;AAE3B;;;;CAIC,GACD,OAAO,MAAMC,QAAQD,QAAQ,cAAa;AAE1C;;;;;;CAMC,GACD,OAAO,MAAME,WAAW,CAACC,YAAsBF,MAAMG,MAAM,CAACD,WAAU"}
@@ -0,0 +1,28 @@
1
+ export * from './config/cli/getCliConfig.js';
2
+ export { type CliConfig, type ReactCompilerConfig, type UserViteConfig } from './config/cli/types.js';
3
+ export * from './config/findProjectRoot.js';
4
+ export * from './config/studio/getStudioConfig.js';
5
+ export * from './config/util/findConfigsPaths.js';
6
+ export * from './config/util/findStudioConfigPath.js';
7
+ export { type ProjectRootResult } from './config/util/recursivelyResolveProjectRoot.js';
8
+ export * from './debug.js';
9
+ export * from './loaders/tsx/tsxWorkerTask.js';
10
+ export * from './SanityCommand.js';
11
+ export * from './services/apiClient.js';
12
+ export * from './services/cliUserConfig.js';
13
+ export * from './services/getCliToken.js';
14
+ export { type Output } from './types.js';
15
+ export * from './util/createExpiringConfig.js';
16
+ export * from './util/getSanityEnvVar.js';
17
+ export * from './util/getSanityUrl.js';
18
+ export * from './util/getUserConfig.js';
19
+ export * from './util/isCi.js';
20
+ export * from './util/isHttpError.js';
21
+ export * from './util/isInteractive.js';
22
+ export * from './util/isTrueish.js';
23
+ export * from './ux/colorizeJson.js';
24
+ export * from './ux/formatObject.js';
25
+ export * from './ux/logSymbols.js';
26
+ export * from './ux/printKeyValue.js';
27
+ export * from './ux/spinner.js';
28
+ export * from './ux/timer.js';