sanity 5.12.0 → 5.12.1-alpha.15

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 (157) hide show
  1. package/bin/sanity +65 -28
  2. package/lib/_chunks-dts/ActiveWorkspaceMatcherContext.d.ts +190 -190
  3. package/lib/_chunks-dts/index.d.ts +11 -11
  4. package/lib/_chunks-dts/types2.d.ts +25 -25
  5. package/lib/_chunks-es/MenuGroup.js +1 -1
  6. package/lib/_chunks-es/PresentationToolGrantsCheck.js +1 -1
  7. package/lib/_chunks-es/index.js +278 -1
  8. package/lib/_chunks-es/index.js.map +1 -1
  9. package/lib/_chunks-es/index2.js +1 -1
  10. package/lib/_chunks-es/index3.js +1 -1
  11. package/lib/_chunks-es/index4.js +1 -2
  12. package/lib/_chunks-es/index4.js.map +1 -1
  13. package/lib/_chunks-es/pane.js +1 -1
  14. package/lib/_chunks-es/resources.js +1 -1
  15. package/lib/_chunks-es/resources3.js +1 -1
  16. package/lib/_chunks-es/resources4.js +1 -1
  17. package/lib/_chunks-es/resources5.js +1 -1
  18. package/lib/_chunks-es/version.js +2 -2
  19. package/lib/_internal.d.ts +2 -3
  20. package/lib/_internal.js +8 -1
  21. package/lib/_internal.js.map +1 -1
  22. package/lib/_singletons.d.ts +102 -102
  23. package/lib/cli.d.ts +1 -42
  24. package/lib/cli.js +2 -1
  25. package/lib/cli.js.map +1 -1
  26. package/lib/desk.js +1 -1
  27. package/lib/index.js +13 -4
  28. package/lib/index.js.map +1 -1
  29. package/lib/presentation.d.ts +2 -2
  30. package/lib/router.d.ts +4 -4
  31. package/lib/structure.js +1 -1
  32. package/package.json +18 -63
  33. package/lib/_chunks-cjs/extractWorkspaceManifest.cjs +0 -395
  34. package/lib/_chunks-cjs/extractWorkspaceManifest.cjs.map +0 -1
  35. package/lib/_chunks-cjs/getStudioWorkspaces.cjs +0 -51
  36. package/lib/_chunks-cjs/getStudioWorkspaces.cjs.map +0 -1
  37. package/lib/_chunks-cjs/mockBrowserEnvironment.cjs +0 -148
  38. package/lib/_chunks-cjs/mockBrowserEnvironment.cjs.map +0 -1
  39. package/lib/_chunks-es/TooltipDelayGroupProvider.js +0 -281
  40. package/lib/_chunks-es/TooltipDelayGroupProvider.js.map +0 -1
  41. package/lib/_chunks-es/_internal.js +0 -4358
  42. package/lib/_chunks-es/_internal.js.map +0 -1
  43. package/lib/_chunks-es/buildAction.js +0 -144
  44. package/lib/_chunks-es/buildAction.js.map +0 -1
  45. package/lib/_chunks-es/buildAction2.js +0 -215
  46. package/lib/_chunks-es/buildAction2.js.map +0 -1
  47. package/lib/_chunks-es/cli.js +0 -33
  48. package/lib/_chunks-es/cli.js.map +0 -1
  49. package/lib/_chunks-es/createAspectAction.js +0 -54
  50. package/lib/_chunks-es/createAspectAction.js.map +0 -1
  51. package/lib/_chunks-es/deleteApiAction.js +0 -67
  52. package/lib/_chunks-es/deleteApiAction.js.map +0 -1
  53. package/lib/_chunks-es/deleteAspectAction.js +0 -52
  54. package/lib/_chunks-es/deleteAspectAction.js.map +0 -1
  55. package/lib/_chunks-es/deleteSchemaAction.js +0 -102
  56. package/lib/_chunks-es/deleteSchemaAction.js.map +0 -1
  57. package/lib/_chunks-es/deployAction.js +0 -116
  58. package/lib/_chunks-es/deployAction.js.map +0 -1
  59. package/lib/_chunks-es/deployAction2.js +0 -211
  60. package/lib/_chunks-es/deployAction2.js.map +0 -1
  61. package/lib/_chunks-es/deployApiAction.js +0 -1697
  62. package/lib/_chunks-es/deployApiAction.js.map +0 -1
  63. package/lib/_chunks-es/deployAspectAction.js +0 -172
  64. package/lib/_chunks-es/deployAspectAction.js.map +0 -1
  65. package/lib/_chunks-es/deploySchemasAction.js +0 -141
  66. package/lib/_chunks-es/deploySchemasAction.js.map +0 -1
  67. package/lib/_chunks-es/determineTargetMediaLibrary.js +0 -43
  68. package/lib/_chunks-es/determineTargetMediaLibrary.js.map +0 -1
  69. package/lib/_chunks-es/devAction.js +0 -53
  70. package/lib/_chunks-es/devAction.js.map +0 -1
  71. package/lib/_chunks-es/devAction2.js +0 -268
  72. package/lib/_chunks-es/devAction2.js.map +0 -1
  73. package/lib/_chunks-es/execScript.js +0 -53
  74. package/lib/_chunks-es/execScript.js.map +0 -1
  75. package/lib/_chunks-es/exportAssetsAction.js +0 -52
  76. package/lib/_chunks-es/exportAssetsAction.js.map +0 -1
  77. package/lib/_chunks-es/extractAction.js +0 -111
  78. package/lib/_chunks-es/extractAction.js.map +0 -1
  79. package/lib/_chunks-es/extractManifestAction.js +0 -103
  80. package/lib/_chunks-es/extractManifestAction.js.map +0 -1
  81. package/lib/_chunks-es/formatSchemaValidation.js +0 -60
  82. package/lib/_chunks-es/formatSchemaValidation.js.map +0 -1
  83. package/lib/_chunks-es/getAppId.js +0 -20
  84. package/lib/_chunks-es/getAppId.js.map +0 -1
  85. package/lib/_chunks-es/getGraphQLAPIs.js +0 -61
  86. package/lib/_chunks-es/getGraphQLAPIs.js.map +0 -1
  87. package/lib/_chunks-es/helpers.js +0 -460
  88. package/lib/_chunks-es/helpers.js.map +0 -1
  89. package/lib/_chunks-es/importAssetsAction.js +0 -242
  90. package/lib/_chunks-es/importAssetsAction.js.map +0 -1
  91. package/lib/_chunks-es/listApisAction.js +0 -38
  92. package/lib/_chunks-es/listApisAction.js.map +0 -1
  93. package/lib/_chunks-es/listSchemasAction.js +0 -112
  94. package/lib/_chunks-es/listSchemasAction.js.map +0 -1
  95. package/lib/_chunks-es/package.js +0 -8
  96. package/lib/_chunks-es/package.js.map +0 -1
  97. package/lib/_chunks-es/previewAction.js +0 -39
  98. package/lib/_chunks-es/previewAction.js.map +0 -1
  99. package/lib/_chunks-es/previewServer.js +0 -197
  100. package/lib/_chunks-es/previewServer.js.map +0 -1
  101. package/lib/_chunks-es/promiseWithResolvers.js +0 -14
  102. package/lib/_chunks-es/promiseWithResolvers.js.map +0 -1
  103. package/lib/_chunks-es/runtime.js +0 -1204
  104. package/lib/_chunks-es/runtime.js.map +0 -1
  105. package/lib/_chunks-es/schemaExtractorApi.js +0 -154
  106. package/lib/_chunks-es/schemaExtractorApi.js.map +0 -1
  107. package/lib/_chunks-es/schemaStoreOutStrings.js +0 -280
  108. package/lib/_chunks-es/schemaStoreOutStrings.js.map +0 -1
  109. package/lib/_chunks-es/servers.js +0 -39
  110. package/lib/_chunks-es/servers.js.map +0 -1
  111. package/lib/_chunks-es/shouldAutoUpdate.js +0 -107
  112. package/lib/_chunks-es/shouldAutoUpdate.js.map +0 -1
  113. package/lib/_chunks-es/timing.js +0 -72
  114. package/lib/_chunks-es/timing.js.map +0 -1
  115. package/lib/_chunks-es/undeployAction.js +0 -64
  116. package/lib/_chunks-es/undeployAction.js.map +0 -1
  117. package/lib/_chunks-es/undeployAction2.js +0 -59
  118. package/lib/_chunks-es/undeployAction2.js.map +0 -1
  119. package/lib/_chunks-es/uniqueProjectIdDataset.js +0 -12
  120. package/lib/_chunks-es/uniqueProjectIdDataset.js.map +0 -1
  121. package/lib/_chunks-es/upgradePackages.js +0 -335
  122. package/lib/_chunks-es/upgradePackages.js.map +0 -1
  123. package/lib/_chunks-es/validateAction.js +0 -103
  124. package/lib/_chunks-es/validateAction.js.map +0 -1
  125. package/lib/_chunks-es/validateAction2.js +0 -377
  126. package/lib/_chunks-es/validateAction2.js.map +0 -1
  127. package/lib/_chunks-es/warnAboutMissingAppId.js +0 -162
  128. package/lib/_chunks-es/warnAboutMissingAppId.js.map +0 -1
  129. package/lib/_chunks-es/withMediaLibraryConfig.js +0 -17
  130. package/lib/_chunks-es/withMediaLibraryConfig.js.map +0 -1
  131. package/lib/_internal/cli/threads/configClient.cjs +0 -13
  132. package/lib/_internal/cli/threads/configClient.cjs.map +0 -1
  133. package/lib/_internal/cli/threads/configClient.d.cts +0 -1
  134. package/lib/_internal/cli/threads/esbuild.cjs +0 -10
  135. package/lib/_internal/cli/threads/esbuild.cjs.map +0 -1
  136. package/lib/_internal/cli/threads/esbuild.d.cts +0 -1
  137. package/lib/_internal/cli/threads/extractManifest.cjs +0 -18
  138. package/lib/_internal/cli/threads/extractManifest.cjs.map +0 -1
  139. package/lib/_internal/cli/threads/extractManifest.d.cts +0 -5
  140. package/lib/_internal/cli/threads/extractSchema.cjs +0 -53
  141. package/lib/_internal/cli/threads/extractSchema.cjs.map +0 -1
  142. package/lib/_internal/cli/threads/extractSchema.d.cts +0 -43
  143. package/lib/_internal/cli/threads/generateStudioManifest.cjs +0 -88
  144. package/lib/_internal/cli/threads/generateStudioManifest.cjs.map +0 -1
  145. package/lib/_internal/cli/threads/generateStudioManifest.d.cts +0 -29
  146. package/lib/_internal/cli/threads/getGraphQLAPIs.cjs +0 -107
  147. package/lib/_internal/cli/threads/getGraphQLAPIs.cjs.map +0 -1
  148. package/lib/_internal/cli/threads/getGraphQLAPIs.d.cts +0 -1
  149. package/lib/_internal/cli/threads/registerBrowserEnv.cjs +0 -4
  150. package/lib/_internal/cli/threads/registerBrowserEnv.cjs.map +0 -1
  151. package/lib/_internal/cli/threads/registerBrowserEnv.d.cts +0 -1
  152. package/lib/_internal/cli/threads/validateDocuments.cjs +0 -356
  153. package/lib/_internal/cli/threads/validateDocuments.cjs.map +0 -1
  154. package/lib/_internal/cli/threads/validateDocuments.d.cts +0 -62
  155. package/lib/_internal/cli/threads/validateSchema.cjs +0 -108
  156. package/lib/_internal/cli/threads/validateSchema.cjs.map +0 -1
  157. package/lib/_internal/cli/threads/validateSchema.d.cts +0 -36
package/bin/sanity CHANGED
@@ -20,7 +20,7 @@ import {readFile, open} from 'node:fs/promises'
20
20
  import {createRequire} from 'node:module'
21
21
  import {dirname, resolve} from 'node:path'
22
22
  import {pathToFileURL} from 'node:url'
23
- import execa from 'execa'
23
+ import {spawn} from 'node:child_process'
24
24
 
25
25
  const require = createRequire(import.meta.url)
26
26
 
@@ -38,8 +38,8 @@ runSanityCli().catch((err) => {
38
38
  * - If the binary is a Node.js script, we either `import()` or `require()` it based on
39
39
  * the extension (cjs/mjs) or the package `type` field. This is prefered as it does
40
40
  * not require spawning a new process.
41
- * - If the binary is not a Node.js script, we spawn it using `execa`, which handles
42
- * things correctly across platforms (windows doesn't enjoy shebangs etc). stdio is
41
+ * - If the binary is not a Node.js script, we spawn it as a child process. On Windows,
42
+ * shebangs are parsed manually and the interpreter is invoked directly. stdio is
43
43
  * inherited from the parent process.
44
44
  *
45
45
  * Note:
@@ -50,10 +50,11 @@ runSanityCli().catch((err) => {
50
50
  */
51
51
  async function runSanityCli() {
52
52
  const {bin, type} = await getSanityCliBin()
53
+ const shebang = await parseShebang(bin)
53
54
 
54
55
  // The optimal case: the binary is a Node.js script - import/require it directly to
55
56
  // prevent needing to spawn a new process
56
- if (await isNodeScript(bin)) {
57
+ if (isNodeScript(bin, shebang)) {
57
58
  if (type === 'module') {
58
59
  await import(pathToFileURL(bin).href)
59
60
  } else {
@@ -62,13 +63,20 @@ async function runSanityCli() {
62
63
  return
63
64
  }
64
65
 
65
- // Fallback: spawn the binary as a child process
66
- const child = execa(bin, process.argv.slice(2), {
67
- stdio: 'inherit',
68
- encoding: null,
69
- buffer: false,
70
- reject: false,
71
- })
66
+ // Fallback: spawn the binary as a child process.
67
+ // Note: because we resolve the `bin` field from `@sanity/cli`'s package.json, the path
68
+ // points to the actual source file, not a cmd-shim wrapper. This means we don't need the
69
+ // full cmd-shim argument escaping that libraries like `cross-spawn` provide - we only need
70
+ // to handle shebangs on Windows, where they are not natively supported by the OS.
71
+ // On Unix, the OS handles shebangs natively.
72
+ let command = bin
73
+ let args = process.argv.slice(2)
74
+ if (process.platform === 'win32' && shebang) {
75
+ command = shebang.interpreter
76
+ args = [...shebang.args, bin, ...process.argv.slice(2)]
77
+ }
78
+
79
+ const child = spawn(command, args, {stdio: 'inherit'})
72
80
 
73
81
  // Forward signals to the child process
74
82
  const signals = ['SIGINT', 'SIGTERM', 'SIGHUP']
@@ -79,7 +87,10 @@ async function runSanityCli() {
79
87
  })
80
88
 
81
89
  try {
82
- const {exitCode} = await child
90
+ const exitCode = await new Promise((resolve, reject) => {
91
+ child.on('error', reject)
92
+ child.on('close', (code) => resolve(code ?? 1))
93
+ })
83
94
  process.exitCode = exitCode
84
95
  } finally {
85
96
  // Clean up signal handlers
@@ -118,12 +129,15 @@ async function getSanityCliBin() {
118
129
  }
119
130
 
120
131
  /**
121
- * Determines if the file at `scriptPath` is a Node.js script by checking its shebang.
122
- * Returns true if:
123
- * - The shebang interpreter is `node` (e.g., `#!/usr/bin/node`, `#!/usr/bin/env node`)
124
- * - The file has a `.js`, `.mjs`, or `.cjs` extension (fallback when no shebang)
132
+ * Parses the shebang from a script file and returns the interpreter and its arguments.
133
+ * Returns `null` if the file has no shebang.
134
+ *
135
+ * Handles both direct paths and `env` invocations:
136
+ * - `#!/usr/bin/node` => `{interpreter: '/usr/bin/node', args: []}`
137
+ * - `#!/usr/bin/env node` => `{interpreter: 'node', args: []}`
138
+ * - `#!/usr/bin/env -S node --flags` => `{interpreter: 'node', args: ['--flags']}`
125
139
  */
126
- async function isNodeScript(scriptPath) {
140
+ async function parseShebang(scriptPath) {
127
141
  let file
128
142
  try {
129
143
  file = await open(scriptPath)
@@ -138,27 +152,50 @@ async function isNodeScript(scriptPath) {
138
152
  const content = buffer.toString('utf8', 0, bytesRead)
139
153
 
140
154
  if (!content.startsWith('#!')) {
141
- // No shebang - fall back to extension check (.js, .mjs, .cjs)
142
- // This is not perfect - but it's better than nothing
143
- return /\.(m?js|cjs)$/.test(scriptPath)
155
+ return null
144
156
  }
145
157
 
146
- // Extract the interpreter, handling both direct paths and `env` invocations:
147
- // `#!/usr/bin/node` => `node`
148
- // `#!/usr/bin/env node` => `node`
149
- // `#!/usr/bin/env -S node --flags` => `node`
150
158
  const firstLine = content.slice(2, content.indexOf('\n')).trim()
151
159
  const parts = firstLine.split(/\s+/)
152
- const interpreter = parts[0].endsWith('/env')
153
- ? parts.find((part, i) => i > 0 && !part.startsWith('-'))
154
- : parts[0]
155
160
 
156
- return interpreter && (interpreter.endsWith('node') || interpreter.endsWith('node.exe'))
161
+ if (parts[0].endsWith('/env')) {
162
+ // `env` invocation: skip flags (e.g. `-S`) to find the actual interpreter
163
+ const interpreterIdx = parts.findIndex((part, i) => i > 0 && !part.startsWith('-'))
164
+ if (interpreterIdx === -1) {
165
+ return null
166
+ }
167
+ return {
168
+ interpreter: parts[interpreterIdx],
169
+ args: parts.slice(interpreterIdx + 1),
170
+ }
171
+ }
172
+
173
+ return {
174
+ interpreter: parts[0],
175
+ args: parts.slice(1),
176
+ }
157
177
  } finally {
158
178
  await file.close()
159
179
  }
160
180
  }
161
181
 
182
+ /**
183
+ * Determines if the file at `scriptPath` is a Node.js script by checking its shebang.
184
+ * Returns true if:
185
+ * - The shebang interpreter is `node` (e.g., `#!/usr/bin/node`, `#!/usr/bin/env node`)
186
+ * - The file has a `.js`, `.mjs`, or `.cjs` extension (fallback when no shebang)
187
+ */
188
+ function isNodeScript(scriptPath, shebang) {
189
+ if (shebang) {
190
+ const {interpreter} = shebang
191
+ return interpreter.endsWith('node') || interpreter.endsWith('node.exe')
192
+ }
193
+
194
+ // No shebang - fall back to extension check (.js, .mjs, .cjs)
195
+ // This is not perfect - but it's better than nothing
196
+ return /\.(m?js|cjs)$/.test(scriptPath)
197
+ }
198
+
162
199
  function determineModuleType(binPath, pkgJson) {
163
200
  if (binPath.endsWith('.cjs')) {
164
201
  return 'commonjs'