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.
- package/bin/sanity +65 -28
- package/lib/_chunks-dts/ActiveWorkspaceMatcherContext.d.ts +190 -190
- package/lib/_chunks-dts/index.d.ts +11 -11
- package/lib/_chunks-dts/types2.d.ts +25 -25
- package/lib/_chunks-es/MenuGroup.js +1 -1
- package/lib/_chunks-es/PresentationToolGrantsCheck.js +1 -1
- package/lib/_chunks-es/index.js +278 -1
- package/lib/_chunks-es/index.js.map +1 -1
- package/lib/_chunks-es/index2.js +1 -1
- package/lib/_chunks-es/index3.js +1 -1
- package/lib/_chunks-es/index4.js +1 -2
- package/lib/_chunks-es/index4.js.map +1 -1
- package/lib/_chunks-es/pane.js +1 -1
- package/lib/_chunks-es/resources.js +1 -1
- package/lib/_chunks-es/resources3.js +1 -1
- package/lib/_chunks-es/resources4.js +1 -1
- package/lib/_chunks-es/resources5.js +1 -1
- package/lib/_chunks-es/version.js +2 -2
- package/lib/_internal.d.ts +2 -3
- package/lib/_internal.js +8 -1
- package/lib/_internal.js.map +1 -1
- package/lib/_singletons.d.ts +102 -102
- package/lib/cli.d.ts +1 -42
- package/lib/cli.js +2 -1
- package/lib/cli.js.map +1 -1
- package/lib/desk.js +1 -1
- package/lib/index.js +13 -4
- package/lib/index.js.map +1 -1
- package/lib/presentation.d.ts +2 -2
- package/lib/router.d.ts +4 -4
- package/lib/structure.js +1 -1
- package/package.json +18 -63
- package/lib/_chunks-cjs/extractWorkspaceManifest.cjs +0 -395
- package/lib/_chunks-cjs/extractWorkspaceManifest.cjs.map +0 -1
- package/lib/_chunks-cjs/getStudioWorkspaces.cjs +0 -51
- package/lib/_chunks-cjs/getStudioWorkspaces.cjs.map +0 -1
- package/lib/_chunks-cjs/mockBrowserEnvironment.cjs +0 -148
- package/lib/_chunks-cjs/mockBrowserEnvironment.cjs.map +0 -1
- package/lib/_chunks-es/TooltipDelayGroupProvider.js +0 -281
- package/lib/_chunks-es/TooltipDelayGroupProvider.js.map +0 -1
- package/lib/_chunks-es/_internal.js +0 -4358
- package/lib/_chunks-es/_internal.js.map +0 -1
- package/lib/_chunks-es/buildAction.js +0 -144
- package/lib/_chunks-es/buildAction.js.map +0 -1
- package/lib/_chunks-es/buildAction2.js +0 -215
- package/lib/_chunks-es/buildAction2.js.map +0 -1
- package/lib/_chunks-es/cli.js +0 -33
- package/lib/_chunks-es/cli.js.map +0 -1
- package/lib/_chunks-es/createAspectAction.js +0 -54
- package/lib/_chunks-es/createAspectAction.js.map +0 -1
- package/lib/_chunks-es/deleteApiAction.js +0 -67
- package/lib/_chunks-es/deleteApiAction.js.map +0 -1
- package/lib/_chunks-es/deleteAspectAction.js +0 -52
- package/lib/_chunks-es/deleteAspectAction.js.map +0 -1
- package/lib/_chunks-es/deleteSchemaAction.js +0 -102
- package/lib/_chunks-es/deleteSchemaAction.js.map +0 -1
- package/lib/_chunks-es/deployAction.js +0 -116
- package/lib/_chunks-es/deployAction.js.map +0 -1
- package/lib/_chunks-es/deployAction2.js +0 -211
- package/lib/_chunks-es/deployAction2.js.map +0 -1
- package/lib/_chunks-es/deployApiAction.js +0 -1697
- package/lib/_chunks-es/deployApiAction.js.map +0 -1
- package/lib/_chunks-es/deployAspectAction.js +0 -172
- package/lib/_chunks-es/deployAspectAction.js.map +0 -1
- package/lib/_chunks-es/deploySchemasAction.js +0 -141
- package/lib/_chunks-es/deploySchemasAction.js.map +0 -1
- package/lib/_chunks-es/determineTargetMediaLibrary.js +0 -43
- package/lib/_chunks-es/determineTargetMediaLibrary.js.map +0 -1
- package/lib/_chunks-es/devAction.js +0 -53
- package/lib/_chunks-es/devAction.js.map +0 -1
- package/lib/_chunks-es/devAction2.js +0 -268
- package/lib/_chunks-es/devAction2.js.map +0 -1
- package/lib/_chunks-es/execScript.js +0 -53
- package/lib/_chunks-es/execScript.js.map +0 -1
- package/lib/_chunks-es/exportAssetsAction.js +0 -52
- package/lib/_chunks-es/exportAssetsAction.js.map +0 -1
- package/lib/_chunks-es/extractAction.js +0 -111
- package/lib/_chunks-es/extractAction.js.map +0 -1
- package/lib/_chunks-es/extractManifestAction.js +0 -103
- package/lib/_chunks-es/extractManifestAction.js.map +0 -1
- package/lib/_chunks-es/formatSchemaValidation.js +0 -60
- package/lib/_chunks-es/formatSchemaValidation.js.map +0 -1
- package/lib/_chunks-es/getAppId.js +0 -20
- package/lib/_chunks-es/getAppId.js.map +0 -1
- package/lib/_chunks-es/getGraphQLAPIs.js +0 -61
- package/lib/_chunks-es/getGraphQLAPIs.js.map +0 -1
- package/lib/_chunks-es/helpers.js +0 -460
- package/lib/_chunks-es/helpers.js.map +0 -1
- package/lib/_chunks-es/importAssetsAction.js +0 -242
- package/lib/_chunks-es/importAssetsAction.js.map +0 -1
- package/lib/_chunks-es/listApisAction.js +0 -38
- package/lib/_chunks-es/listApisAction.js.map +0 -1
- package/lib/_chunks-es/listSchemasAction.js +0 -112
- package/lib/_chunks-es/listSchemasAction.js.map +0 -1
- package/lib/_chunks-es/package.js +0 -8
- package/lib/_chunks-es/package.js.map +0 -1
- package/lib/_chunks-es/previewAction.js +0 -39
- package/lib/_chunks-es/previewAction.js.map +0 -1
- package/lib/_chunks-es/previewServer.js +0 -197
- package/lib/_chunks-es/previewServer.js.map +0 -1
- package/lib/_chunks-es/promiseWithResolvers.js +0 -14
- package/lib/_chunks-es/promiseWithResolvers.js.map +0 -1
- package/lib/_chunks-es/runtime.js +0 -1204
- package/lib/_chunks-es/runtime.js.map +0 -1
- package/lib/_chunks-es/schemaExtractorApi.js +0 -154
- package/lib/_chunks-es/schemaExtractorApi.js.map +0 -1
- package/lib/_chunks-es/schemaStoreOutStrings.js +0 -280
- package/lib/_chunks-es/schemaStoreOutStrings.js.map +0 -1
- package/lib/_chunks-es/servers.js +0 -39
- package/lib/_chunks-es/servers.js.map +0 -1
- package/lib/_chunks-es/shouldAutoUpdate.js +0 -107
- package/lib/_chunks-es/shouldAutoUpdate.js.map +0 -1
- package/lib/_chunks-es/timing.js +0 -72
- package/lib/_chunks-es/timing.js.map +0 -1
- package/lib/_chunks-es/undeployAction.js +0 -64
- package/lib/_chunks-es/undeployAction.js.map +0 -1
- package/lib/_chunks-es/undeployAction2.js +0 -59
- package/lib/_chunks-es/undeployAction2.js.map +0 -1
- package/lib/_chunks-es/uniqueProjectIdDataset.js +0 -12
- package/lib/_chunks-es/uniqueProjectIdDataset.js.map +0 -1
- package/lib/_chunks-es/upgradePackages.js +0 -335
- package/lib/_chunks-es/upgradePackages.js.map +0 -1
- package/lib/_chunks-es/validateAction.js +0 -103
- package/lib/_chunks-es/validateAction.js.map +0 -1
- package/lib/_chunks-es/validateAction2.js +0 -377
- package/lib/_chunks-es/validateAction2.js.map +0 -1
- package/lib/_chunks-es/warnAboutMissingAppId.js +0 -162
- package/lib/_chunks-es/warnAboutMissingAppId.js.map +0 -1
- package/lib/_chunks-es/withMediaLibraryConfig.js +0 -17
- package/lib/_chunks-es/withMediaLibraryConfig.js.map +0 -1
- package/lib/_internal/cli/threads/configClient.cjs +0 -13
- package/lib/_internal/cli/threads/configClient.cjs.map +0 -1
- package/lib/_internal/cli/threads/configClient.d.cts +0 -1
- package/lib/_internal/cli/threads/esbuild.cjs +0 -10
- package/lib/_internal/cli/threads/esbuild.cjs.map +0 -1
- package/lib/_internal/cli/threads/esbuild.d.cts +0 -1
- package/lib/_internal/cli/threads/extractManifest.cjs +0 -18
- package/lib/_internal/cli/threads/extractManifest.cjs.map +0 -1
- package/lib/_internal/cli/threads/extractManifest.d.cts +0 -5
- package/lib/_internal/cli/threads/extractSchema.cjs +0 -53
- package/lib/_internal/cli/threads/extractSchema.cjs.map +0 -1
- package/lib/_internal/cli/threads/extractSchema.d.cts +0 -43
- package/lib/_internal/cli/threads/generateStudioManifest.cjs +0 -88
- package/lib/_internal/cli/threads/generateStudioManifest.cjs.map +0 -1
- package/lib/_internal/cli/threads/generateStudioManifest.d.cts +0 -29
- package/lib/_internal/cli/threads/getGraphQLAPIs.cjs +0 -107
- package/lib/_internal/cli/threads/getGraphQLAPIs.cjs.map +0 -1
- package/lib/_internal/cli/threads/getGraphQLAPIs.d.cts +0 -1
- package/lib/_internal/cli/threads/registerBrowserEnv.cjs +0 -4
- package/lib/_internal/cli/threads/registerBrowserEnv.cjs.map +0 -1
- package/lib/_internal/cli/threads/registerBrowserEnv.d.cts +0 -1
- package/lib/_internal/cli/threads/validateDocuments.cjs +0 -356
- package/lib/_internal/cli/threads/validateDocuments.cjs.map +0 -1
- package/lib/_internal/cli/threads/validateDocuments.d.cts +0 -62
- package/lib/_internal/cli/threads/validateSchema.cjs +0 -108
- package/lib/_internal/cli/threads/validateSchema.cjs.map +0 -1
- 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
|
|
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
|
|
42
|
-
*
|
|
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 (
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
|
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
|
-
*
|
|
122
|
-
* Returns
|
|
123
|
-
*
|
|
124
|
-
*
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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'
|