@sanity/cli 7.2.1 → 7.2.2
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/dist/actions/build/buildApp.js +10 -14
- package/dist/actions/build/buildApp.js.map +1 -1
- package/dist/actions/build/buildStaticFiles.js +4 -4
- package/dist/actions/build/buildStaticFiles.js.map +1 -1
- package/dist/actions/build/buildStudio.js +10 -14
- package/dist/actions/build/buildStudio.js.map +1 -1
- package/oclif.manifest.json +86 -86
- package/package.json +4 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { rm } from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { styleText } from 'node:util';
|
|
4
|
-
import { AppBuildTrace, buildDebug,
|
|
4
|
+
import { AppBuildTrace, buildDebug, resolveVendorBuildConfig } from '@sanity/cli-build/_internal/build';
|
|
5
5
|
import { getCliTelemetry, getLocalPackageVersion, getTimer, isInteractive } from '@sanity/cli-core';
|
|
6
6
|
import { confirm, logSymbols, spinner } from '@sanity/cli-core/ux';
|
|
7
7
|
import { parse as semverParse } from 'semver';
|
|
@@ -167,29 +167,25 @@ import { handlePrereleaseVersions } from './handlePrereleaseVersions.js';
|
|
|
167
167
|
spin = spinner(`Building Sanity application`).start();
|
|
168
168
|
const trace = getCliTelemetry().trace(AppBuildTrace);
|
|
169
169
|
trace.start();
|
|
170
|
-
let
|
|
170
|
+
let autoUpdates;
|
|
171
171
|
if (autoUpdatesEnabled) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}),
|
|
180
|
-
...autoUpdatesImports
|
|
181
|
-
}
|
|
172
|
+
autoUpdates = {
|
|
173
|
+
cssUrls: autoUpdatesCssUrls,
|
|
174
|
+
imports: autoUpdatesImports,
|
|
175
|
+
vendor: await resolveVendorBuildConfig({
|
|
176
|
+
cwd: workDir,
|
|
177
|
+
isApp: true
|
|
178
|
+
})
|
|
182
179
|
};
|
|
183
180
|
}
|
|
184
181
|
try {
|
|
185
182
|
timer.start('bundleStudio');
|
|
186
183
|
const bundle = await buildStaticFiles({
|
|
187
184
|
appTitle: options.appTitle,
|
|
188
|
-
|
|
185
|
+
autoUpdates,
|
|
189
186
|
basePath,
|
|
190
187
|
cwd: workDir,
|
|
191
188
|
entry: options.entry,
|
|
192
|
-
importMap,
|
|
193
189
|
isApp: true,
|
|
194
190
|
minify: options.minify,
|
|
195
191
|
outputDir,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/build/buildApp.ts"],"sourcesContent":["import {rm} from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {AppBuildTrace, buildDebug, buildVendorDependencies} from '@sanity/cli-build/_internal/build'\nimport {\n type CliConfig,\n getCliTelemetry,\n getLocalPackageVersion,\n getTimer,\n isInteractive,\n type Output,\n UserViteConfig,\n} from '@sanity/cli-core'\nimport {confirm, logSymbols, spinner, type SpinnerInstance} from '@sanity/cli-core/ux'\nimport {parse as semverParse} from 'semver'\n\nimport {getAppId} from '../../util/appId.js'\nimport {compareDependencyVersions} from '../../util/compareDependencyVersions.js'\nimport {formatModuleSizes, sortModulesBySize} from '../../util/moduleFormatUtils.js'\nimport {warnAboutMissingAppId} from '../../util/warnAboutMissingAppId.js'\nimport {buildStaticFiles} from './buildStaticFiles.js'\nimport {determineBasePath} from './determineBasePath.js'\nimport {getAutoUpdatesCssUrls, getAutoUpdatesImportMap} from './getAutoUpdatesImportMap.js'\nimport {getAppEnvironmentVariables} from './getEnvironmentVariables.js'\nimport {handlePrereleaseVersions} from './handlePrereleaseVersions.js'\nimport {type BuildOptions} from './types.js'\n\ninterface InternalBuildOptions {\n appId: string | undefined\n appTitle: string | undefined\n autoUpdatesEnabled: boolean\n calledFromDeploy: boolean | undefined\n determineBasePath: () => string\n entry: string | undefined\n minify: boolean\n outDir: string | undefined\n output: Output\n reactCompiler: CliConfig['reactCompiler']\n schemaExtraction: CliConfig['schemaExtraction']\n sourceMap: boolean\n stats: boolean\n unattendedMode: boolean\n vite: UserViteConfig | undefined\n workDir: string\n}\n\n/**\n * Build the Sanity app.\n *\n * @internal\n */\nexport async function buildApp(options: BuildOptions): Promise<void> {\n const {cliConfig, flags, outDir, output, workDir} = options\n\n await internalBuildApp({\n appId: getAppId(cliConfig),\n appTitle: cliConfig && 'app' in cliConfig ? cliConfig.app?.title : undefined,\n autoUpdatesEnabled: options.autoUpdatesEnabled,\n calledFromDeploy: options.calledFromDeploy,\n determineBasePath: () => determineBasePath(cliConfig, 'app', output),\n entry: cliConfig && 'app' in cliConfig ? cliConfig.app?.entry : undefined,\n minify: flags.minify,\n outDir,\n output,\n reactCompiler: cliConfig && 'reactCompiler' in cliConfig ? cliConfig.reactCompiler : undefined,\n schemaExtraction: cliConfig?.schemaExtraction,\n sourceMap: Boolean(flags['source-maps']),\n stats: flags.stats,\n unattendedMode: flags.yes,\n vite: cliConfig.vite,\n workDir,\n })\n}\n\n/**\n * Internal build app that avoids depending on flags for CLI config.\n * @param options - options for the build\n */\nasync function internalBuildApp(options: InternalBuildOptions): Promise<void> {\n buildDebug(`Building app`)\n\n const {appId, determineBasePath, outDir, output, workDir} = options\n let {autoUpdatesEnabled} = options\n const unattendedMode = options.unattendedMode\n\n const timer = getTimer()\n\n const defaultOutputDir = path.resolve(path.join(workDir, 'dist'))\n const outputDir = path.resolve(outDir || defaultOutputDir)\n\n const installedSdkVersion = await getLocalPackageVersion('@sanity/sdk-react', workDir)\n const installedSanityVersion = await getLocalPackageVersion('sanity', workDir)\n\n if (!installedSdkVersion) {\n output.error(`Failed to find installed @sanity/sdk-react version`, {exit: 1})\n return\n }\n\n let autoUpdatesImports = {}\n let autoUpdatesCssUrls: string[] = []\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSDKVersion = semverParse(installedSdkVersion)?.version\n if (!cleanSDKVersion) {\n output.error(`Failed to parse installed SDK version: ${installedSdkVersion}`, {exit: 1})\n return\n }\n\n // Sanity might not be installed, but if it is, we want to auto update it.\n const cleanSanityVersion = semverParse(installedSanityVersion)?.version\n\n const autoUpdatedPackages = [\n {name: '@sanity/sdk', version: cleanSDKVersion},\n {name: '@sanity/sdk-react', version: cleanSDKVersion},\n ...(cleanSanityVersion\n ? [{cssFile: 'index.css', name: 'sanity' as const, version: cleanSanityVersion}]\n : []),\n ]\n autoUpdatesImports = getAutoUpdatesImportMap(autoUpdatedPackages, {appId})\n autoUpdatesCssUrls = getAutoUpdatesCssUrls(autoUpdatedPackages, {appId})\n\n output.log(`${logSymbols.info} Building with auto-updates enabled`)\n\n // Warn if auto updates enabled but no appId configured.\n // Skip when called from deploy, since deploy handles appId itself\n // (prompts the user and tells them to add it to config).\n if (!appId && !options.calledFromDeploy) {\n warnAboutMissingAppId({appType: 'app', output})\n }\n\n // Check the versions\n const {mismatched, unresolvedPrerelease} = await compareDependencyVersions(\n autoUpdatedPackages,\n workDir,\n {appId},\n )\n\n if (unresolvedPrerelease.length > 0) {\n await handlePrereleaseVersions({output, unattendedMode, unresolvedPrerelease})\n autoUpdatesImports = {}\n autoUpdatesCssUrls = []\n autoUpdatesEnabled = false\n }\n\n if (mismatched.length > 0 && autoUpdatesEnabled) {\n const versionMismatchWarning =\n `The following local package versions are different from the versions currently served at runtime.\\n` +\n `When using auto updates, we recommend that you test locally with the same versions before deploying. \\n\\n` +\n `${mismatched.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')}`\n\n // If it is non-interactive or in unattended mode, we don't want to prompt\n if (isInteractive() && !unattendedMode) {\n const shouldContinue = await confirm({\n default: false,\n message: styleText('yellow', `${versionMismatchWarning} \\n\\nContinue anyway?`),\n })\n\n if (!shouldContinue) {\n output.error('Declined to continue with build', {exit: 1})\n return\n }\n } else {\n // if non-interactive or unattended, just show the warning\n output.warn(versionMismatchWarning)\n }\n }\n }\n\n const envVarKeys = Object.keys(getAppEnvironmentVariables())\n if (envVarKeys.length > 0) {\n output.log('\\nIncluding the following environment variables as part of the JavaScript bundle:')\n for (const key of envVarKeys) output.log(`- ${key}`)\n output.log('')\n }\n\n let shouldClean = true\n if (outputDir !== defaultOutputDir && !unattendedMode && isInteractive()) {\n shouldClean = await confirm({\n default: true,\n message: `Do you want to delete the existing directory (${outputDir}) first?`,\n })\n }\n\n const basePath = determineBasePath()\n\n let spin: SpinnerInstance\n if (shouldClean) {\n timer.start('cleanOutputFolder')\n spin = spinner('Clean output folder').start()\n await rm(outputDir, {force: true, recursive: true})\n const cleanDuration = timer.end('cleanOutputFolder')\n spin.text = `Clean output folder (${cleanDuration.toFixed(0)}ms)`\n spin.succeed()\n }\n\n spin = spinner(`Building Sanity application`).start()\n\n const trace = getCliTelemetry().trace(AppBuildTrace)\n trace.start()\n\n let importMap: {imports?: Record<string, string>} | undefined\n\n if (autoUpdatesEnabled) {\n importMap = {\n imports: {\n ...(await buildVendorDependencies({basePath, cwd: workDir, isApp: true, outputDir})),\n ...autoUpdatesImports,\n },\n }\n }\n\n try {\n timer.start('bundleStudio')\n\n const bundle = await buildStaticFiles({\n appTitle: options.appTitle,\n autoUpdatesCssUrls: autoUpdatesCssUrls.length > 0 ? autoUpdatesCssUrls : undefined,\n basePath,\n cwd: workDir,\n entry: options.entry,\n importMap,\n isApp: true,\n minify: options.minify,\n outputDir,\n reactCompiler: options.reactCompiler,\n schemaExtraction: options.schemaExtraction,\n sourceMap: options.sourceMap,\n vite: options.vite,\n })\n\n trace.log({\n outputSize: bundle.chunks\n .flatMap((chunk) => chunk.modules.flatMap((mod) => mod.renderedLength))\n .reduce((sum, n) => sum + n, 0),\n })\n const buildDuration = timer.end('bundleStudio')\n\n spin.text = `Build Sanity application (${buildDuration.toFixed(0)}ms)`\n spin.succeed()\n\n if (options.stats) {\n output.log('\\nLargest module files:')\n output.log(formatModuleSizes(sortModulesBySize(bundle.chunks).slice(0, 15)))\n }\n\n trace.complete()\n } catch (error) {\n spin.fail()\n trace.error(error)\n const message = error instanceof Error ? error.message : String(error)\n buildDebug(`Failed to build Sanity application`, {error})\n output.error(`Failed to build Sanity application: ${message}`, {exit: 1})\n }\n}\n"],"names":["rm","path","styleText","AppBuildTrace","buildDebug","buildVendorDependencies","getCliTelemetry","getLocalPackageVersion","getTimer","isInteractive","confirm","logSymbols","spinner","parse","semverParse","getAppId","compareDependencyVersions","formatModuleSizes","sortModulesBySize","warnAboutMissingAppId","buildStaticFiles","determineBasePath","getAutoUpdatesCssUrls","getAutoUpdatesImportMap","getAppEnvironmentVariables","handlePrereleaseVersions","buildApp","options","cliConfig","flags","outDir","output","workDir","internalBuildApp","appId","appTitle","app","title","undefined","autoUpdatesEnabled","calledFromDeploy","entry","minify","reactCompiler","schemaExtraction","sourceMap","Boolean","stats","unattendedMode","yes","vite","timer","defaultOutputDir","resolve","join","outputDir","installedSdkVersion","installedSanityVersion","error","exit","autoUpdatesImports","autoUpdatesCssUrls","cleanSDKVersion","version","cleanSanityVersion","autoUpdatedPackages","name","cssFile","log","info","appType","mismatched","unresolvedPrerelease","length","versionMismatchWarning","map","mod","pkg","installed","remote","shouldContinue","default","message","warn","envVarKeys","Object","keys","key","shouldClean","basePath","spin","start","force","recursive","cleanDuration","end","text","toFixed","succeed","trace","importMap","imports","cwd","isApp","bundle","outputSize","chunks","flatMap","chunk","modules","renderedLength","reduce","sum","n","buildDuration","slice","complete","fail","Error","String"],"mappings":"AAAA,SAAQA,EAAE,QAAO,mBAAkB;AACnC,OAAOC,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAQC,aAAa,EAAEC,UAAU,EAAEC,uBAAuB,QAAO,oCAAmC;AACpG,SAEEC,eAAe,EACfC,sBAAsB,EACtBC,QAAQ,EACRC,aAAa,QAGR,mBAAkB;AACzB,SAAQC,OAAO,EAAEC,UAAU,EAAEC,OAAO,QAA6B,sBAAqB;AACtF,SAAQC,SAASC,WAAW,Q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AC5BK,MAAMvB,QAAQuB,IAAI;QACpB;QAEAiD,MAAM/B,GAAG,CAAC;YACRqC,YAAYD,OAAOE,MAAM,CACtBC,OAAO,CAAC,CAACC,QAAUA,MAAMC,OAAO,CAACF,OAAO,CAAC,CAAC/B,MAAQA,IAAIkC,cAAc,GACpEC,MAAM,CAAC,CAACC,KAAKC,IAAMD,MAAMC,GAAG;QACjC;QACA,MAAMC,gBAAgB/D,MAAM4C,GAAG,CAAC;QAEhCL,KAAKM,IAAI,GAAG,CAAC,0BAA0B,EAAEkB,cAAcjB,OAAO,CAAC,GAAG,GAAG,CAAC;QACtEP,KAAKQ,OAAO;QAEZ,IAAIvE,QAAQoB,KAAK,EAAE;YACjBhB,OAAOqC,GAAG,CAAC;YACXrC,OAAOqC,GAAG,CAACnD,kBAAkBC,kBAAkBsF,OAAOE,MAAM,EAAES,KAAK,CAAC,GAAG;QACzE;QAEAhB,MAAMiB,QAAQ;IAChB,EAAE,OAAO1D,OAAO;QACdgC,KAAK2B,IAAI;QACTlB,MAAMzC,KAAK,CAACA;QACZ,MAAMwB,UAAUxB,iBAAiB4D,QAAQ5D,MAAMwB,OAAO,GAAGqC,OAAO7D;QAChEtD,WAAW,CAAC,kCAAkC,CAAC,EAAE;YAACsD;QAAK;QACvD3B,OAAO2B,KAAK,CAAC,CAAC,oCAAoC,EAAEwB,SAAS,EAAE;YAACvB,MAAM;QAAC;IACzE;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/build/buildApp.ts"],"sourcesContent":["import {rm} from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {\n AppBuildTrace,\n buildDebug,\n resolveVendorBuildConfig,\n} from '@sanity/cli-build/_internal/build'\nimport {\n type CliConfig,\n getCliTelemetry,\n getLocalPackageVersion,\n getTimer,\n isInteractive,\n type Output,\n UserViteConfig,\n} from '@sanity/cli-core'\nimport {confirm, logSymbols, spinner, type SpinnerInstance} from '@sanity/cli-core/ux'\nimport {parse as semverParse} from 'semver'\n\nimport {getAppId} from '../../util/appId.js'\nimport {compareDependencyVersions} from '../../util/compareDependencyVersions.js'\nimport {formatModuleSizes, sortModulesBySize} from '../../util/moduleFormatUtils.js'\nimport {warnAboutMissingAppId} from '../../util/warnAboutMissingAppId.js'\nimport {buildStaticFiles} from './buildStaticFiles.js'\nimport {determineBasePath} from './determineBasePath.js'\nimport {getAutoUpdatesCssUrls, getAutoUpdatesImportMap} from './getAutoUpdatesImportMap.js'\nimport {getAppEnvironmentVariables} from './getEnvironmentVariables.js'\nimport {handlePrereleaseVersions} from './handlePrereleaseVersions.js'\nimport {type BuildOptions} from './types.js'\n\ninterface InternalBuildOptions {\n appId: string | undefined\n appTitle: string | undefined\n autoUpdatesEnabled: boolean\n calledFromDeploy: boolean | undefined\n determineBasePath: () => string\n entry: string | undefined\n minify: boolean\n outDir: string | undefined\n output: Output\n reactCompiler: CliConfig['reactCompiler']\n schemaExtraction: CliConfig['schemaExtraction']\n sourceMap: boolean\n stats: boolean\n unattendedMode: boolean\n vite: UserViteConfig | undefined\n workDir: string\n}\n\n/**\n * Build the Sanity app.\n *\n * @internal\n */\nexport async function buildApp(options: BuildOptions): Promise<void> {\n const {cliConfig, flags, outDir, output, workDir} = options\n\n await internalBuildApp({\n appId: getAppId(cliConfig),\n appTitle: cliConfig && 'app' in cliConfig ? cliConfig.app?.title : undefined,\n autoUpdatesEnabled: options.autoUpdatesEnabled,\n calledFromDeploy: options.calledFromDeploy,\n determineBasePath: () => determineBasePath(cliConfig, 'app', output),\n entry: cliConfig && 'app' in cliConfig ? cliConfig.app?.entry : undefined,\n minify: flags.minify,\n outDir,\n output,\n reactCompiler: cliConfig && 'reactCompiler' in cliConfig ? cliConfig.reactCompiler : undefined,\n schemaExtraction: cliConfig?.schemaExtraction,\n sourceMap: Boolean(flags['source-maps']),\n stats: flags.stats,\n unattendedMode: flags.yes,\n vite: cliConfig.vite,\n workDir,\n })\n}\n\n/**\n * Internal build app that avoids depending on flags for CLI config.\n * @param options - options for the build\n */\nasync function internalBuildApp(options: InternalBuildOptions): Promise<void> {\n buildDebug(`Building app`)\n\n const {appId, determineBasePath, outDir, output, workDir} = options\n let {autoUpdatesEnabled} = options\n const unattendedMode = options.unattendedMode\n\n const timer = getTimer()\n\n const defaultOutputDir = path.resolve(path.join(workDir, 'dist'))\n const outputDir = path.resolve(outDir || defaultOutputDir)\n\n const installedSdkVersion = await getLocalPackageVersion('@sanity/sdk-react', workDir)\n const installedSanityVersion = await getLocalPackageVersion('sanity', workDir)\n\n if (!installedSdkVersion) {\n output.error(`Failed to find installed @sanity/sdk-react version`, {exit: 1})\n return\n }\n\n let autoUpdatesImports = {}\n let autoUpdatesCssUrls: string[] = []\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSDKVersion = semverParse(installedSdkVersion)?.version\n if (!cleanSDKVersion) {\n output.error(`Failed to parse installed SDK version: ${installedSdkVersion}`, {exit: 1})\n return\n }\n\n // Sanity might not be installed, but if it is, we want to auto update it.\n const cleanSanityVersion = semverParse(installedSanityVersion)?.version\n\n const autoUpdatedPackages = [\n {name: '@sanity/sdk', version: cleanSDKVersion},\n {name: '@sanity/sdk-react', version: cleanSDKVersion},\n ...(cleanSanityVersion\n ? [{cssFile: 'index.css', name: 'sanity' as const, version: cleanSanityVersion}]\n : []),\n ]\n autoUpdatesImports = getAutoUpdatesImportMap(autoUpdatedPackages, {appId})\n autoUpdatesCssUrls = getAutoUpdatesCssUrls(autoUpdatedPackages, {appId})\n\n output.log(`${logSymbols.info} Building with auto-updates enabled`)\n\n // Warn if auto updates enabled but no appId configured.\n // Skip when called from deploy, since deploy handles appId itself\n // (prompts the user and tells them to add it to config).\n if (!appId && !options.calledFromDeploy) {\n warnAboutMissingAppId({appType: 'app', output})\n }\n\n // Check the versions\n const {mismatched, unresolvedPrerelease} = await compareDependencyVersions(\n autoUpdatedPackages,\n workDir,\n {appId},\n )\n\n if (unresolvedPrerelease.length > 0) {\n await handlePrereleaseVersions({output, unattendedMode, unresolvedPrerelease})\n autoUpdatesImports = {}\n autoUpdatesCssUrls = []\n autoUpdatesEnabled = false\n }\n\n if (mismatched.length > 0 && autoUpdatesEnabled) {\n const versionMismatchWarning =\n `The following local package versions are different from the versions currently served at runtime.\\n` +\n `When using auto updates, we recommend that you test locally with the same versions before deploying. \\n\\n` +\n `${mismatched.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')}`\n\n // If it is non-interactive or in unattended mode, we don't want to prompt\n if (isInteractive() && !unattendedMode) {\n const shouldContinue = await confirm({\n default: false,\n message: styleText('yellow', `${versionMismatchWarning} \\n\\nContinue anyway?`),\n })\n\n if (!shouldContinue) {\n output.error('Declined to continue with build', {exit: 1})\n return\n }\n } else {\n // if non-interactive or unattended, just show the warning\n output.warn(versionMismatchWarning)\n }\n }\n }\n\n const envVarKeys = Object.keys(getAppEnvironmentVariables())\n if (envVarKeys.length > 0) {\n output.log('\\nIncluding the following environment variables as part of the JavaScript bundle:')\n for (const key of envVarKeys) output.log(`- ${key}`)\n output.log('')\n }\n\n let shouldClean = true\n if (outputDir !== defaultOutputDir && !unattendedMode && isInteractive()) {\n shouldClean = await confirm({\n default: true,\n message: `Do you want to delete the existing directory (${outputDir}) first?`,\n })\n }\n\n const basePath = determineBasePath()\n\n let spin: SpinnerInstance\n if (shouldClean) {\n timer.start('cleanOutputFolder')\n spin = spinner('Clean output folder').start()\n await rm(outputDir, {force: true, recursive: true})\n const cleanDuration = timer.end('cleanOutputFolder')\n spin.text = `Clean output folder (${cleanDuration.toFixed(0)}ms)`\n spin.succeed()\n }\n\n spin = spinner(`Building Sanity application`).start()\n\n const trace = getCliTelemetry().trace(AppBuildTrace)\n trace.start()\n\n let autoUpdates\n if (autoUpdatesEnabled) {\n autoUpdates = {\n cssUrls: autoUpdatesCssUrls,\n imports: autoUpdatesImports,\n vendor: await resolveVendorBuildConfig({cwd: workDir, isApp: true}),\n }\n }\n\n try {\n timer.start('bundleStudio')\n\n const bundle = await buildStaticFiles({\n appTitle: options.appTitle,\n autoUpdates,\n basePath,\n cwd: workDir,\n entry: options.entry,\n isApp: true,\n minify: options.minify,\n outputDir,\n reactCompiler: options.reactCompiler,\n schemaExtraction: options.schemaExtraction,\n sourceMap: options.sourceMap,\n vite: options.vite,\n })\n\n trace.log({\n outputSize: bundle.chunks\n .flatMap((chunk) => chunk.modules.flatMap((mod) => mod.renderedLength))\n .reduce((sum, n) => sum + n, 0),\n })\n const buildDuration = timer.end('bundleStudio')\n\n spin.text = `Build Sanity application (${buildDuration.toFixed(0)}ms)`\n spin.succeed()\n\n if (options.stats) {\n output.log('\\nLargest module files:')\n output.log(formatModuleSizes(sortModulesBySize(bundle.chunks).slice(0, 15)))\n }\n\n trace.complete()\n } catch (error) {\n spin.fail()\n trace.error(error)\n const message = error instanceof Error ? error.message : String(error)\n buildDebug(`Failed to build Sanity application`, {error})\n output.error(`Failed to build Sanity application: ${message}`, {exit: 1})\n }\n}\n"],"names":["rm","path","styleText","AppBuildTrace","buildDebug","resolveVendorBuildConfig","getCliTelemetry","getLocalPackageVersion","getTimer","isInteractive","confirm","logSymbols","spinner","parse","semverParse","getAppId","compareDependencyVersions","formatModuleSizes","sortModulesBySize","warnAboutMissingAppId","buildStaticFiles","determineBasePath","getAutoUpdatesCssUrls","getAutoUpdatesImportMap","getAppEnvironmentVariables","handlePrereleaseVersions","buildApp","options","cliConfig","flags","outDir","output","workDir","internalBuildApp","appId","appTitle","app","title","undefined","autoUpdatesEnabled","calledFromDeploy","entry","minify","reactCompiler","schemaExtraction","sourceMap","Boolean","stats","unattendedMode","yes","vite","timer","defaultOutputDir","resolve","join","outputDir","installedSdkVersion","installedSanityVersion","error","exit","autoUpdatesImports","autoUpdatesCssUrls","cleanSDKVersion","version","cleanSanityVersion","autoUpdatedPackages","name","cssFile","log","info","appType","mismatched","unresolvedPrerelease","length","versionMismatchWarning","map","mod","pkg","installed","remote","shouldContinue","default","message","warn","envVarKeys","Object","keys","key","shouldClean","basePath","spin","start","force","recursive","cleanDuration","end","text","toFixed","succeed","trace","autoUpdates","cssUrls","imports","vendor","cwd","isApp","bundle","outputSize","chunks","flatMap","chunk","modules","renderedLength","reduce","sum","n","buildDuration","slice","complete","fail","Error","String"],"mappings":"AAAA,SAAQA,EAAE,QAAO,mBAAkB;AACnC,OAAOC,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SACEC,aAAa,EACbC,UAAU,EACVC,wBAAwB,QACnB,oCAAmC;AAC1C,SAEEC,eAAe,EACfC,sBAAsB,EACtBC,QAAQ,EACRC,aAAa,QAGR,mBAAkB;AACzB,SAAQC,OAAO,EAAEC,UAAU,EAAEC,OAAO,QAA6B,sBAAqB;AACtF,SAAQC,SAASC,WAAW,QAAO,SAAQ;AAE3C,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,yBAAyB,QAAO,0CAAyC;AACjF,SAAQC,iBAAiB,EAAEC,iBAAiB,QAAO,kCAAiC;AACpF,SAAQC,qBAAqB,QAAO,sCAAqC;AACzE,SAAQC,gBAAgB,QAAO,wBAAuB;AACtD,SAAQC,iBAAiB,QAAO,yBAAwB;AACxD,SAAQC,qBAAqB,EAAEC,uBAAuB,QAAO,+BAA8B;AAC3F,SAAQC,0BAA0B,QAAO,+BAA8B;AACvE,SAAQC,wBAAwB,QAAO,gCAA+B;AAsBtE;;;;CAIC,GACD,OAAO,eAAeC,SAASC,OAAqB;IAClD,MAAM,EAACC,SAAS,EAAEC,KAAK,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAC,GAAGL;IAEpD,MAAMM,iBAAiB;QACrBC,OAAOnB,SAASa;QAChBO,UAAUP,aAAa,SAASA,YAAYA,UAAUQ,GAAG,EAAEC,QAAQC;QACnEC,oBAAoBZ,QAAQY,kBAAkB;QAC9CC,kBAAkBb,QAAQa,gBAAgB;QAC1CnB,mBAAmB,IAAMA,kBAAkBO,WAAW,OAA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AAoC,EAAEwB,SAAS,EAAE;YAACvB,MAAM;QAAC;IACzE;AACF"}
|
|
@@ -7,7 +7,7 @@ import { getAppEnvironmentVariables, getStudioEnvironmentVariables } from './get
|
|
|
7
7
|
*
|
|
8
8
|
* @internal
|
|
9
9
|
*/ export async function buildStaticFiles(options) {
|
|
10
|
-
const { appTitle,
|
|
10
|
+
const { appTitle, autoUpdates, basePath, cwd, entry, isApp, minify = true, outputDir, reactCompiler, schemaExtraction, sourceMap = false, vite: extendViteConfig } = options;
|
|
11
11
|
buildDebug('Writing Sanity runtime files');
|
|
12
12
|
await writeSanityRuntime({
|
|
13
13
|
appTitle,
|
|
@@ -30,11 +30,10 @@ import { getAppEnvironmentVariables, getStudioEnvironmentVariables } from './get
|
|
|
30
30
|
buildDebug('Resolving vite config');
|
|
31
31
|
const mode = 'production';
|
|
32
32
|
let viteConfig = await getViteConfig({
|
|
33
|
-
|
|
33
|
+
autoUpdates,
|
|
34
34
|
basePath,
|
|
35
35
|
cwd,
|
|
36
36
|
getEnvironmentVariables,
|
|
37
|
-
importMap,
|
|
38
37
|
isApp,
|
|
39
38
|
minify,
|
|
40
39
|
mode,
|
|
@@ -44,11 +43,12 @@ import { getAppEnvironmentVariables, getStudioEnvironmentVariables } from './get
|
|
|
44
43
|
sourceMap
|
|
45
44
|
});
|
|
46
45
|
if (extendViteConfig) {
|
|
46
|
+
const defaultViteConfig = viteConfig;
|
|
47
47
|
viteConfig = await extendViteConfigWithUserConfig({
|
|
48
48
|
command: 'build',
|
|
49
49
|
mode
|
|
50
50
|
}, viteConfig, extendViteConfig);
|
|
51
|
-
viteConfig = await finalizeViteConfig(viteConfig);
|
|
51
|
+
viteConfig = await finalizeViteConfig(viteConfig, defaultViteConfig);
|
|
52
52
|
}
|
|
53
53
|
const fromPath = path.join(cwd, 'static');
|
|
54
54
|
// Copy files placed in /static to the built /static
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/build/buildStaticFiles.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {\n buildDebug,\n copyDir,\n extendViteConfigWithUserConfig,\n finalizeViteConfig,\n getViteConfig,\n writeFavicons,\n writeSanityRuntime,\n} from '@sanity/cli-build/_internal/build'\nimport {type CliConfig, type UserViteConfig} from '@sanity/cli-core'\nimport {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport {build} from 'vite'\n\nimport {\n getAppEnvironmentVariables,\n getStudioEnvironmentVariables,\n} from './getEnvironmentVariables.js'\n\nexport interface ChunkModule {\n name: string\n renderedLength: number\n}\n\nexport interface ChunkStats {\n modules: ChunkModule[]\n name: string\n}\n\ninterface StaticBuildOptions {\n basePath: string\n cwd: string\n outputDir: string\n\n appTitle?: string\n
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/build/buildStaticFiles.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {\n type AutoUpdatesBuildConfig,\n buildDebug,\n copyDir,\n extendViteConfigWithUserConfig,\n finalizeViteConfig,\n getViteConfig,\n writeFavicons,\n writeSanityRuntime,\n} from '@sanity/cli-build/_internal/build'\nimport {type CliConfig, type UserViteConfig} from '@sanity/cli-core'\nimport {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport {build} from 'vite'\n\nimport {\n getAppEnvironmentVariables,\n getStudioEnvironmentVariables,\n} from './getEnvironmentVariables.js'\n\nexport interface ChunkModule {\n name: string\n renderedLength: number\n}\n\nexport interface ChunkStats {\n modules: ChunkModule[]\n name: string\n}\n\ninterface StaticBuildOptions {\n basePath: string\n cwd: string\n outputDir: string\n\n appTitle?: string\n autoUpdates?: AutoUpdatesBuildConfig\n entry?: string\n isApp?: boolean\n minify?: boolean\n profile?: boolean\n reactCompiler?: ReactCompilerConfig\n schemaExtraction?: CliConfig['schemaExtraction']\n sourceMap?: boolean\n vite?: UserViteConfig\n}\n\n/**\n * Builds static files\n *\n * @internal\n */\nexport async function buildStaticFiles(\n options: StaticBuildOptions,\n): Promise<{chunks: ChunkStats[]}> {\n const {\n appTitle,\n autoUpdates,\n basePath,\n cwd,\n entry,\n isApp,\n minify = true,\n outputDir,\n reactCompiler,\n schemaExtraction,\n sourceMap = false,\n vite: extendViteConfig,\n } = options\n\n buildDebug('Writing Sanity runtime files')\n await writeSanityRuntime({\n appTitle,\n basePath,\n cwd,\n entry,\n isApp,\n reactStrictMode: false,\n watch: false,\n })\n\n function getEnvironmentVariables() {\n return isApp\n ? getAppEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n : getStudioEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n }\n\n buildDebug('Resolving vite config')\n const mode = 'production'\n let viteConfig = await getViteConfig({\n autoUpdates,\n basePath,\n cwd,\n getEnvironmentVariables,\n isApp,\n minify,\n mode,\n outputDir,\n reactCompiler,\n schemaExtraction,\n sourceMap,\n })\n\n if (extendViteConfig) {\n const defaultViteConfig = viteConfig\n viteConfig = await extendViteConfigWithUserConfig(\n {command: 'build', mode},\n viteConfig,\n extendViteConfig,\n )\n viteConfig = await finalizeViteConfig(viteConfig, defaultViteConfig)\n }\n\n const fromPath = path.join(cwd, 'static')\n // Copy files placed in /static to the built /static\n buildDebug(`Copying static files from ${fromPath} to output dir`)\n const staticPath = path.join(outputDir, 'static')\n await copyDir(fromPath, staticPath)\n\n // Write favicons, not overwriting ones that already exist, to static folder\n buildDebug('Writing favicons to output dir')\n const faviconBasePath = `${basePath.replace(/\\/+$/, '')}/static`\n await writeFavicons(faviconBasePath, staticPath)\n\n buildDebug('Bundling using vite')\n const bundle = await build(viteConfig)\n buildDebug('Bundling complete')\n\n // For typescript only - this shouldn't ever be the case given we're not watching\n if (Array.isArray(bundle) || !('output' in bundle)) {\n return {chunks: []}\n }\n\n const stats: ChunkStats[] = []\n for (const chunk of bundle.output) {\n if (chunk.type !== 'chunk') {\n continue\n }\n\n stats.push({\n modules: Object.entries(chunk.modules).map(([rawFilePath, chunkModule]) => {\n const filePath = rawFilePath.startsWith('\\u0000')\n ? rawFilePath.slice('\\u0000'.length)\n : rawFilePath\n\n return {\n name: path.isAbsolute(filePath) ? path.relative(cwd, filePath) : filePath,\n renderedLength: chunkModule.renderedLength,\n }\n }),\n name: chunk.name,\n })\n }\n\n return {chunks: stats}\n}\n"],"names":["path","buildDebug","copyDir","extendViteConfigWithUserConfig","finalizeViteConfig","getViteConfig","writeFavicons","writeSanityRuntime","build","getAppEnvironmentVariables","getStudioEnvironmentVariables","buildStaticFiles","options","appTitle","autoUpdates","basePath","cwd","entry","isApp","minify","outputDir","reactCompiler","schemaExtraction","sourceMap","vite","extendViteConfig","reactStrictMode","watch","getEnvironmentVariables","jsonEncode","prefix","mode","viteConfig","defaultViteConfig","command","fromPath","join","staticPath","faviconBasePath","replace","bundle","Array","isArray","chunks","stats","chunk","output","type","push","modules","Object","entries","map","rawFilePath","chunkModule","filePath","startsWith","slice","length","name","isAbsolute","relative","renderedLength"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B,SAEEC,UAAU,EACVC,OAAO,EACPC,8BAA8B,EAC9BC,kBAAkB,EAClBC,aAAa,EACbC,aAAa,EACbC,kBAAkB,QACb,oCAAmC;AAG1C,SAAQC,KAAK,QAAO,OAAM;AAE1B,SACEC,0BAA0B,EAC1BC,6BAA6B,QACxB,+BAA8B;AA6BrC;;;;CAIC,GACD,OAAO,eAAeC,iBACpBC,OAA2B;IAE3B,MAAM,EACJC,QAAQ,EACRC,WAAW,EACXC,QAAQ,EACRC,GAAG,EACHC,KAAK,EACLC,KAAK,EACLC,SAAS,IAAI,EACbC,SAAS,EACTC,aAAa,EACbC,gBAAgB,EAChBC,YAAY,KAAK,EACjBC,MAAMC,gBAAgB,EACvB,GAAGb;IAEJX,WAAW;IACX,MAAMM,mBAAmB;QACvBM;QACAE;QACAC;QACAC;QACAC;QACAQ,iBAAiB;QACjBC,OAAO;IACT;IAEA,SAASC;QACP,OAAOV,QACHT,2BAA2B;YAACoB,YAAY;YAAMC,QAAQ;QAAc,KACpEpB,8BAA8B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U,CAACL,YAAYvD,KAAK6D,QAAQ,CAAC7C,KAAKuC,YAAYA;oBACjEO,gBAAgBR,YAAYQ,cAAc;gBAC5C;YACF;YACAH,MAAMd,MAAMc,IAAI;QAClB;IACF;IAEA,OAAO;QAAChB,QAAQC;IAAK;AACvB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { rm } from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { styleText } from 'node:util';
|
|
4
|
-
import { buildDebug,
|
|
4
|
+
import { buildDebug, checkStudioDependencyVersions, resolveVendorBuildConfig, StudioBuildTrace } from '@sanity/cli-build/_internal/build';
|
|
5
5
|
import { getCliTelemetry, getLocalPackageVersion, getTimer, isInteractive } from '@sanity/cli-core';
|
|
6
6
|
import { confirm, logSymbols, select, spinner } from '@sanity/cli-core/ux';
|
|
7
7
|
import { parse as semverParse } from 'semver';
|
|
@@ -217,27 +217,23 @@ import { handlePrereleaseVersions } from './handlePrereleaseVersions.js';
|
|
|
217
217
|
spin = spinner(`Build Sanity Studio`).start();
|
|
218
218
|
const trace = getCliTelemetry().trace(StudioBuildTrace);
|
|
219
219
|
trace.start();
|
|
220
|
-
let
|
|
220
|
+
let autoUpdates;
|
|
221
221
|
if (autoUpdatesEnabled) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}),
|
|
230
|
-
...autoUpdatesImports
|
|
231
|
-
}
|
|
222
|
+
autoUpdates = {
|
|
223
|
+
cssUrls: autoUpdatesCssUrls,
|
|
224
|
+
imports: autoUpdatesImports,
|
|
225
|
+
vendor: await resolveVendorBuildConfig({
|
|
226
|
+
cwd: workDir,
|
|
227
|
+
isApp: false
|
|
228
|
+
})
|
|
232
229
|
};
|
|
233
230
|
}
|
|
234
231
|
try {
|
|
235
232
|
timer.start('bundleStudio');
|
|
236
233
|
const bundle = await buildStaticFiles({
|
|
237
|
-
|
|
234
|
+
autoUpdates,
|
|
238
235
|
basePath,
|
|
239
236
|
cwd: workDir,
|
|
240
|
-
importMap,
|
|
241
237
|
minify,
|
|
242
238
|
outputDir,
|
|
243
239
|
reactCompiler,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/build/buildStudio.ts"],"sourcesContent":["import {rm} from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {\n buildDebug,\n buildVendorDependencies,\n checkStudioDependencyVersions,\n StudioBuildTrace,\n} from '@sanity/cli-build/_internal/build'\nimport {\n type CliConfig,\n getCliTelemetry,\n getLocalPackageVersion,\n getTimer,\n isInteractive,\n type Output,\n UserViteConfig,\n} from '@sanity/cli-core'\nimport {confirm, logSymbols, select, spinner, type SpinnerInstance} from '@sanity/cli-core/ux'\nimport {parse as semverParse} from 'semver'\n\nimport {getAppId} from '../../util/appId.js'\nimport {compareDependencyVersions} from '../../util/compareDependencyVersions.js'\nimport {determineIsApp} from '../../util/determineIsApp.js'\nimport {formatModuleSizes, sortModulesBySize} from '../../util/moduleFormatUtils.js'\nimport {getPackageManagerChoice} from '../../util/packageManager/packageManagerChoice.js'\nimport {upgradePackages} from '../../util/packageManager/upgradePackages.js'\nimport {warnAboutMissingAppId} from '../../util/warnAboutMissingAppId.js'\nimport {buildStaticFiles} from './buildStaticFiles.js'\nimport {checkRequiredDependencies} from './checkRequiredDependencies.js'\nimport {determineBasePath} from './determineBasePath.js'\nimport {getAutoUpdatesCssUrls, getAutoUpdatesImportMap} from './getAutoUpdatesImportMap.js'\nimport {getStudioEnvironmentVariables} from './getEnvironmentVariables.js'\nimport {handlePrereleaseVersions} from './handlePrereleaseVersions.js'\nimport {type BuildOptions} from './types.js'\n\ninterface InternalBuildOptions {\n appId: string | undefined\n autoUpdatesEnabled: boolean\n calledFromDeploy: boolean | undefined\n determineBasePath: () => string\n isApp: boolean\n minify: boolean\n outDir: string | undefined\n output: Output\n projectId: string | undefined\n reactCompiler: CliConfig['reactCompiler']\n schemaExtraction: CliConfig['schemaExtraction']\n sourceMap: boolean\n stats: boolean\n unattendedMode: boolean\n upgradePackages(options: {packages: [name: string, version: string][]}): Promise<void>\n vite: UserViteConfig | undefined\n workDir: string\n}\n\n/**\n * Build the Sanity Studio.\n *\n * @internal\n */\nexport async function buildStudio(options: BuildOptions): Promise<void> {\n const {calledFromDeploy, cliConfig, flags, outDir, output, workDir} = options\n\n const upgradePkgs = async (options: {\n packages: [name: string, version: string][]\n }): Promise<void> => {\n await upgradePackages(\n {\n packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,\n packages: options.packages,\n },\n {output, workDir},\n )\n }\n\n await internalBuildStudio({\n appId: getAppId(cliConfig),\n autoUpdatesEnabled: options.autoUpdatesEnabled,\n calledFromDeploy,\n determineBasePath: () => determineBasePath(cliConfig, 'studio', output),\n isApp: determineIsApp(cliConfig),\n minify: Boolean(flags.minify),\n outDir,\n output,\n projectId: cliConfig?.api?.projectId,\n reactCompiler: cliConfig.reactCompiler,\n schemaExtraction: cliConfig.schemaExtraction,\n sourceMap: Boolean(flags['source-maps']),\n stats: flags.stats,\n unattendedMode: Boolean(flags.yes),\n upgradePackages: upgradePkgs,\n vite: cliConfig.vite,\n workDir,\n })\n}\n\n/**\n * Internal build studio that avoids depending on flags for CLI config.\n * @param options - options for the build\n */\nasync function internalBuildStudio(options: InternalBuildOptions): Promise<void> {\n buildDebug(`Building studio`)\n\n const timer = getTimer()\n const {\n appId,\n determineBasePath,\n isApp,\n minify,\n outDir,\n output,\n projectId,\n reactCompiler,\n schemaExtraction,\n sourceMap,\n stats,\n unattendedMode,\n upgradePackages,\n vite,\n workDir,\n } = options\n const defaultOutputDir = path.resolve(path.join(workDir, 'dist'))\n const outputDir = path.resolve(outDir || defaultOutputDir)\n\n await checkStudioDependencyVersions(workDir, output)\n\n // If the check resulted in a dependency install, the CLI command will be re-run,\n // thus we want to exit early\n const {installedSanityVersion} = await checkRequiredDependencies({\n isApp,\n output,\n workDir,\n })\n\n let autoUpdatesEnabled = options.autoUpdatesEnabled\n\n let autoUpdatesImports = {}\n let autoUpdatesCssUrls: string[] = []\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSanityVersion = semverParse(installedSanityVersion)?.version\n if (!cleanSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n\n output.log(`${logSymbols.info} Building with auto-updates enabled`)\n\n // Warn if auto updates enabled but no appId configured.\n // Skip when called from deploy, since deploy handles appId itself\n // (prompts the user and tells them to add it to config).\n if (!appId && !options.calledFromDeploy) {\n warnAboutMissingAppId({appType: 'studio', output, projectId})\n }\n\n const installedVisionVersion = await getLocalPackageVersion('@sanity/vision', workDir)\n const cleanVisionVersion = installedVisionVersion\n ? semverParse(installedVisionVersion)?.version\n : undefined\n\n const sanityDependencies = [\n {cssFile: 'index.css', name: 'sanity', version: cleanSanityVersion},\n ...(cleanVisionVersion\n ? [{cssFile: 'index.css', name: '@sanity/vision' as const, version: cleanVisionVersion}]\n : [{name: '@sanity/vision' as const, version: cleanSanityVersion}]),\n ]\n autoUpdatesImports = getAutoUpdatesImportMap(sanityDependencies, {appId})\n\n autoUpdatesCssUrls = getAutoUpdatesCssUrls(sanityDependencies, {appId})\n\n // Check the versions\n const {mismatched, unresolvedPrerelease} = await compareDependencyVersions(\n sanityDependencies,\n workDir,\n {appId},\n )\n\n if (unresolvedPrerelease.length > 0) {\n await handlePrereleaseVersions({output, unattendedMode, unresolvedPrerelease})\n autoUpdatesImports = {}\n autoUpdatesCssUrls = []\n autoUpdatesEnabled = false\n }\n\n if (mismatched.length > 0 && autoUpdatesEnabled) {\n const versionMismatchWarning =\n `The following local package versions are different from the versions currently served at runtime.\\n` +\n `When using auto updates, we recommend that you test locally with the same versions before deploying. \\n\\n` +\n `${mismatched.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')}`\n\n // If it is non-interactive or in unattended mode, we don't want to prompt\n if (isInteractive() && !unattendedMode) {\n const choice = await select({\n choices: [\n {\n name: `Upgrade local versions (recommended). You will need to run the build command again`,\n value: 'upgrade',\n },\n {\n name: `Upgrade and proceed with build`,\n value: 'upgrade-and-proceed',\n },\n {\n name: `Continue anyway`,\n value: 'continue',\n },\n {name: 'Cancel', value: 'cancel'},\n ],\n default: 'upgrade',\n message: styleText(\n 'yellow',\n `${logSymbols.warning} ${versionMismatchWarning}\\n\\nDo you want to upgrade local versions before deploying?`,\n ),\n })\n\n if (choice === 'cancel') {\n output.error('Declined to continue with build', {exit: 1})\n return\n }\n\n if (choice === 'upgrade' || choice === 'upgrade-and-proceed') {\n await upgradePackages({\n packages: mismatched.map((res) => [res.pkg, res.remote]),\n })\n\n if (choice === 'upgrade') {\n return\n }\n }\n } else {\n // if non-interactive or unattended, just show the warning\n output.warn(versionMismatchWarning)\n }\n }\n }\n\n const envVarKeys = Object.keys(getStudioEnvironmentVariables())\n if (envVarKeys.length > 0) {\n output.log('\\nIncluding the following environment variables as part of the JavaScript bundle:')\n for (const key of envVarKeys) {\n output.log(`- ${key}`)\n }\n output.log('')\n }\n\n let shouldClean = true\n if (outputDir !== defaultOutputDir && !unattendedMode && isInteractive()) {\n shouldClean = await confirm({\n default: true,\n message: `Do you want to delete the existing directory (${outputDir}) first?`,\n })\n }\n\n // Determine base path for built studio\n const basePath = determineBasePath()\n\n if (schemaExtraction?.enabled) {\n output.log(`${logSymbols.info} Building with schema extraction enabled`)\n }\n\n let spin: SpinnerInstance\n if (shouldClean) {\n timer.start('cleanOutputFolder')\n spin = spinner('Clean output folder').start()\n await rm(outputDir, {force: true, recursive: true})\n const cleanDuration = timer.end('cleanOutputFolder')\n spin.text = `Clean output folder (${cleanDuration.toFixed(0)}ms)`\n spin.succeed()\n }\n\n spin = spinner(`Build Sanity Studio`).start()\n\n const trace = getCliTelemetry().trace(StudioBuildTrace)\n trace.start()\n\n let importMap\n\n if (autoUpdatesEnabled) {\n importMap = {\n imports: {\n ...(await buildVendorDependencies({basePath, cwd: workDir, isApp: false, outputDir})),\n ...autoUpdatesImports,\n },\n }\n }\n\n try {\n timer.start('bundleStudio')\n\n const bundle = await buildStaticFiles({\n autoUpdatesCssUrls: autoUpdatesCssUrls.length > 0 ? autoUpdatesCssUrls : undefined,\n basePath,\n cwd: workDir,\n importMap,\n minify,\n outputDir,\n reactCompiler,\n schemaExtraction,\n sourceMap,\n vite,\n })\n\n trace.log({\n outputSize: bundle.chunks\n .flatMap((chunk) => chunk.modules.flatMap((mod) => mod.renderedLength))\n .reduce((sum, n) => sum + n, 0),\n })\n const buildDuration = timer.end('bundleStudio')\n\n spin.text = `Build Sanity Studio (${buildDuration.toFixed(0)}ms)`\n spin.succeed()\n\n trace.complete()\n if (stats) {\n output.log('\\nLargest module files:')\n output.log(formatModuleSizes(sortModulesBySize(bundle.chunks).slice(0, 15)))\n }\n } catch (error) {\n spin.fail()\n trace.error(error)\n const message = error instanceof Error ? error.message : String(error)\n buildDebug(`Failed to build Sanity Studio`, {error})\n output.error(`Failed to build Sanity Studio: ${message}`, {exit: 1})\n }\n}\n"],"names":["rm","path","styleText","buildDebug","buildVendorDependencies","checkStudioDependencyVersions","StudioBuildTrace","getCliTelemetry","getLocalPackageVersion","getTimer","isInteractive","confirm","logSymbols","select","spinner","parse","semverParse","getAppId","compareDependencyVersions","determineIsApp","formatModuleSizes","sortModulesBySize","getPackageManagerChoice","upgradePackages","warnAboutMissingAppId","buildStaticFiles","checkRequiredDependencies","determineBasePath","getAutoUpdatesCssUrls","getAutoUpdatesImportMap","getStudioEnvironmentVariables","handlePrereleaseVersions","buildStudio","options","calledFromDeploy","cliConfig","flags","outDir","output","workDir","upgradePkgs","packageManager","interactive","chosen","packages","internalBuildStudio","appId","autoUpdatesEnabled","isApp","minify","Boolean","projectId","api","reactCompiler","schemaExtraction","sourceMap","stats","unattendedMode","yes","vite","timer","defaultOutputDir","resolve","join","outputDir","installedSanityVersion","autoUpdatesImports","autoUpdatesCssUrls","cleanSanityVersion","version","Error","log","info","appType","installedVisionVersion","cleanVisionVersion","undefined","sanityDependencies","cssFile","name","mismatched","unresolvedPrerelease","length","versionMismatchWarning","map","mod","pkg","installed","remote","choice","choices","value","default","message","warning","error","exit","res","warn","envVarKeys","Object","keys","key","shouldClean","basePath","enabled","spin","start","force","recursive","cleanDuration","end","text","toFixed","succeed","trace","importMap","imports","cwd","bundle","outputSize","chunks","flatMap","chunk","modules","renderedLength","reduce","sum","n","buildDuration","complete","slice","fail","String"],"mappings":"AAAA,SAAQA,EAAE,QAAO,mBAAkB;AACnC,OAAOC,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SACEC,UAAU,EACVC,uBAAuB,EACvBC,6BAA6B,EAC7BC,gBAAgB,QACX,oCAAmC;AAC1C,SAEEC,eAAe,EACfC,sBAAsB,EACtBC,QAAQ,EACRC,aAAa,QAGR,mBAAkB;AACzB,SAAQC,OAAO,EAAEC,UAAU,EAAEC,MAAM,EAAEC,OAAO,QAA6B,sBAAqB;AAC9F,SAAQC,SAASC,WAAW,QAAO,SAAQ;AAE3C,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,yBAAyB,QAAO,0CAAyC;AACjF,SAAQC,cAAc,QAAO,+BAA8B;AAC3D,SAAQC,iBAAiB,EAAEC,iBAAiB,QAAO,kCAAiC;AACpF,SAAQC,uBAAuB,QAAO,oDAAmD;AACzF,SAAQC,eAAe,QAAO,+CAA8C;AAC5E,SAAQC,qBAAqB,QAAO,sCAAqC;AACzE,SAAQC,gBAAgB,QAAO,wBAAuB;AACtD,SAAQC,yBAAyB,QAAO,iCAAgC;AACxE,SAAQC,iBAAiB,QAAO,yBAAwB;AACxD,SAAQC,qBAAqB,EAAEC,uBAAuB,QAAO,+BAA8B;AAC3F,SAAQC,6BAA6B,QAAO,+BAA8B;AAC1E,SAAQC,wBAAwB,QAAO,gCAA+B;AAuBtE;;;;CAIC,GACD,OAAO,eAAeC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OAAO;oBAAOgB;gBAAS,EAAE;gBACpF,GAAGE,kBAAkB;YACvB;QACF;IACF;IAEA,IAAI;QACFN,MAAM+C,KAAK,CAAC;QAEZ,MAAMY,SAAS,MAAM9F,iBAAiB;YACpC0C,oBAAoBA,mBAAmBe,MAAM,GAAG,IAAIf,qBAAqBS;YACzE4B;YACAc,KAAK/E;YACL6E;YACAnE;YACAe;YACAX;YACAC;YACAC;YACAI;QACF;QAEAwD,MAAM5C,GAAG,CAAC;YACRiD,YAAYD,OAAOE,MAAM,CACtBC,OAAO,CAAC,CAACC,QAAUA,MAAMC,OAAO,CAACF,OAAO,CAAC,CAACrC,MAAQA,IAAIwC,cAAc,GACpEC,MAAM,CAAC,CAACC,KAAKC,IAAMD,MAAMC,GAAG;QACjC;QACA,MAAMC,gBAAgBrE,MAAMmD,GAAG,CAAC;QAEhCL,KAAKM,IAAI,GAAG,CAAC,qBAAqB,EAAEiB,cAAchB,OAAO,CAAC,GAAG,GAAG,CAAC;QACjEP,KAAKQ,OAAO;QAEZC,MAAMe,QAAQ;QACd,IAAI1E,OAAO;YACTlB,OAAOiC,GAAG,CAAC;YACXjC,OAAOiC,GAAG,CAACnD,kBAAkBC,kBAAkBkG,OAAOE,MAAM,EAAEU,KAAK,CAAC,GAAG;QACzE;IACF,EAAE,OAAOpC,OAAO;QACdW,KAAK0B,IAAI;QACTjB,MAAMpB,KAAK,CAACA;QACZ,MAAMF,UAAUE,iBAAiBzB,QAAQyB,MAAMF,OAAO,GAAGwC,OAAOtC;QAChE5F,WAAW,CAAC,6BAA6B,CAAC,EAAE;YAAC4F;QAAK;QAClDzD,OAAOyD,KAAK,CAAC,CAAC,+BAA+B,EAAEF,SAAS,EAAE;YAACG,MAAM;QAAC;IACpE;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/build/buildStudio.ts"],"sourcesContent":["import {rm} from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {\n buildDebug,\n checkStudioDependencyVersions,\n resolveVendorBuildConfig,\n StudioBuildTrace,\n} from '@sanity/cli-build/_internal/build'\nimport {\n type CliConfig,\n getCliTelemetry,\n getLocalPackageVersion,\n getTimer,\n isInteractive,\n type Output,\n UserViteConfig,\n} from '@sanity/cli-core'\nimport {confirm, logSymbols, select, spinner, type SpinnerInstance} from '@sanity/cli-core/ux'\nimport {parse as semverParse} from 'semver'\n\nimport {getAppId} from '../../util/appId.js'\nimport {compareDependencyVersions} from '../../util/compareDependencyVersions.js'\nimport {determineIsApp} from '../../util/determineIsApp.js'\nimport {formatModuleSizes, sortModulesBySize} from '../../util/moduleFormatUtils.js'\nimport {getPackageManagerChoice} from '../../util/packageManager/packageManagerChoice.js'\nimport {upgradePackages} from '../../util/packageManager/upgradePackages.js'\nimport {warnAboutMissingAppId} from '../../util/warnAboutMissingAppId.js'\nimport {buildStaticFiles} from './buildStaticFiles.js'\nimport {checkRequiredDependencies} from './checkRequiredDependencies.js'\nimport {determineBasePath} from './determineBasePath.js'\nimport {getAutoUpdatesCssUrls, getAutoUpdatesImportMap} from './getAutoUpdatesImportMap.js'\nimport {getStudioEnvironmentVariables} from './getEnvironmentVariables.js'\nimport {handlePrereleaseVersions} from './handlePrereleaseVersions.js'\nimport {type BuildOptions} from './types.js'\n\ninterface InternalBuildOptions {\n appId: string | undefined\n autoUpdatesEnabled: boolean\n calledFromDeploy: boolean | undefined\n determineBasePath: () => string\n isApp: boolean\n minify: boolean\n outDir: string | undefined\n output: Output\n projectId: string | undefined\n reactCompiler: CliConfig['reactCompiler']\n schemaExtraction: CliConfig['schemaExtraction']\n sourceMap: boolean\n stats: boolean\n unattendedMode: boolean\n upgradePackages(options: {packages: [name: string, version: string][]}): Promise<void>\n vite: UserViteConfig | undefined\n workDir: string\n}\n\n/**\n * Build the Sanity Studio.\n *\n * @internal\n */\nexport async function buildStudio(options: BuildOptions): Promise<void> {\n const {calledFromDeploy, cliConfig, flags, outDir, output, workDir} = options\n\n const upgradePkgs = async (options: {\n packages: [name: string, version: string][]\n }): Promise<void> => {\n await upgradePackages(\n {\n packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,\n packages: options.packages,\n },\n {output, workDir},\n )\n }\n\n await internalBuildStudio({\n appId: getAppId(cliConfig),\n autoUpdatesEnabled: options.autoUpdatesEnabled,\n calledFromDeploy,\n determineBasePath: () => determineBasePath(cliConfig, 'studio', output),\n isApp: determineIsApp(cliConfig),\n minify: Boolean(flags.minify),\n outDir,\n output,\n projectId: cliConfig?.api?.projectId,\n reactCompiler: cliConfig.reactCompiler,\n schemaExtraction: cliConfig.schemaExtraction,\n sourceMap: Boolean(flags['source-maps']),\n stats: flags.stats,\n unattendedMode: Boolean(flags.yes),\n upgradePackages: upgradePkgs,\n vite: cliConfig.vite,\n workDir,\n })\n}\n\n/**\n * Internal build studio that avoids depending on flags for CLI config.\n * @param options - options for the build\n */\nasync function internalBuildStudio(options: InternalBuildOptions): Promise<void> {\n buildDebug(`Building studio`)\n\n const timer = getTimer()\n const {\n appId,\n determineBasePath,\n isApp,\n minify,\n outDir,\n output,\n projectId,\n reactCompiler,\n schemaExtraction,\n sourceMap,\n stats,\n unattendedMode,\n upgradePackages,\n vite,\n workDir,\n } = options\n const defaultOutputDir = path.resolve(path.join(workDir, 'dist'))\n const outputDir = path.resolve(outDir || defaultOutputDir)\n\n await checkStudioDependencyVersions(workDir, output)\n\n // If the check resulted in a dependency install, the CLI command will be re-run,\n // thus we want to exit early\n const {installedSanityVersion} = await checkRequiredDependencies({\n isApp,\n output,\n workDir,\n })\n\n let autoUpdatesEnabled = options.autoUpdatesEnabled\n\n let autoUpdatesImports = {}\n let autoUpdatesCssUrls: string[] = []\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSanityVersion = semverParse(installedSanityVersion)?.version\n if (!cleanSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n\n output.log(`${logSymbols.info} Building with auto-updates enabled`)\n\n // Warn if auto updates enabled but no appId configured.\n // Skip when called from deploy, since deploy handles appId itself\n // (prompts the user and tells them to add it to config).\n if (!appId && !options.calledFromDeploy) {\n warnAboutMissingAppId({appType: 'studio', output, projectId})\n }\n\n const installedVisionVersion = await getLocalPackageVersion('@sanity/vision', workDir)\n const cleanVisionVersion = installedVisionVersion\n ? semverParse(installedVisionVersion)?.version\n : undefined\n\n const sanityDependencies = [\n {cssFile: 'index.css', name: 'sanity', version: cleanSanityVersion},\n ...(cleanVisionVersion\n ? [{cssFile: 'index.css', name: '@sanity/vision' as const, version: cleanVisionVersion}]\n : [{name: '@sanity/vision' as const, version: cleanSanityVersion}]),\n ]\n autoUpdatesImports = getAutoUpdatesImportMap(sanityDependencies, {appId})\n\n autoUpdatesCssUrls = getAutoUpdatesCssUrls(sanityDependencies, {appId})\n\n // Check the versions\n const {mismatched, unresolvedPrerelease} = await compareDependencyVersions(\n sanityDependencies,\n workDir,\n {appId},\n )\n\n if (unresolvedPrerelease.length > 0) {\n await handlePrereleaseVersions({output, unattendedMode, unresolvedPrerelease})\n autoUpdatesImports = {}\n autoUpdatesCssUrls = []\n autoUpdatesEnabled = false\n }\n\n if (mismatched.length > 0 && autoUpdatesEnabled) {\n const versionMismatchWarning =\n `The following local package versions are different from the versions currently served at runtime.\\n` +\n `When using auto updates, we recommend that you test locally with the same versions before deploying. \\n\\n` +\n `${mismatched.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')}`\n\n // If it is non-interactive or in unattended mode, we don't want to prompt\n if (isInteractive() && !unattendedMode) {\n const choice = await select({\n choices: [\n {\n name: `Upgrade local versions (recommended). You will need to run the build command again`,\n value: 'upgrade',\n },\n {\n name: `Upgrade and proceed with build`,\n value: 'upgrade-and-proceed',\n },\n {\n name: `Continue anyway`,\n value: 'continue',\n },\n {name: 'Cancel', value: 'cancel'},\n ],\n default: 'upgrade',\n message: styleText(\n 'yellow',\n `${logSymbols.warning} ${versionMismatchWarning}\\n\\nDo you want to upgrade local versions before deploying?`,\n ),\n })\n\n if (choice === 'cancel') {\n output.error('Declined to continue with build', {exit: 1})\n return\n }\n\n if (choice === 'upgrade' || choice === 'upgrade-and-proceed') {\n await upgradePackages({\n packages: mismatched.map((res) => [res.pkg, res.remote]),\n })\n\n if (choice === 'upgrade') {\n return\n }\n }\n } else {\n // if non-interactive or unattended, just show the warning\n output.warn(versionMismatchWarning)\n }\n }\n }\n\n const envVarKeys = Object.keys(getStudioEnvironmentVariables())\n if (envVarKeys.length > 0) {\n output.log('\\nIncluding the following environment variables as part of the JavaScript bundle:')\n for (const key of envVarKeys) {\n output.log(`- ${key}`)\n }\n output.log('')\n }\n\n let shouldClean = true\n if (outputDir !== defaultOutputDir && !unattendedMode && isInteractive()) {\n shouldClean = await confirm({\n default: true,\n message: `Do you want to delete the existing directory (${outputDir}) first?`,\n })\n }\n\n // Determine base path for built studio\n const basePath = determineBasePath()\n\n if (schemaExtraction?.enabled) {\n output.log(`${logSymbols.info} Building with schema extraction enabled`)\n }\n\n let spin: SpinnerInstance\n if (shouldClean) {\n timer.start('cleanOutputFolder')\n spin = spinner('Clean output folder').start()\n await rm(outputDir, {force: true, recursive: true})\n const cleanDuration = timer.end('cleanOutputFolder')\n spin.text = `Clean output folder (${cleanDuration.toFixed(0)}ms)`\n spin.succeed()\n }\n\n spin = spinner(`Build Sanity Studio`).start()\n\n const trace = getCliTelemetry().trace(StudioBuildTrace)\n trace.start()\n\n let autoUpdates\n if (autoUpdatesEnabled) {\n autoUpdates = {\n cssUrls: autoUpdatesCssUrls,\n imports: autoUpdatesImports,\n vendor: await resolveVendorBuildConfig({cwd: workDir, isApp: false}),\n }\n }\n\n try {\n timer.start('bundleStudio')\n\n const bundle = await buildStaticFiles({\n autoUpdates,\n basePath,\n cwd: workDir,\n minify,\n outputDir,\n reactCompiler,\n schemaExtraction,\n sourceMap,\n vite,\n })\n\n trace.log({\n outputSize: bundle.chunks\n .flatMap((chunk) => chunk.modules.flatMap((mod) => mod.renderedLength))\n .reduce((sum, n) => sum + n, 0),\n })\n const buildDuration = timer.end('bundleStudio')\n\n spin.text = `Build Sanity Studio (${buildDuration.toFixed(0)}ms)`\n spin.succeed()\n\n trace.complete()\n if (stats) {\n output.log('\\nLargest module files:')\n output.log(formatModuleSizes(sortModulesBySize(bundle.chunks).slice(0, 15)))\n }\n } catch (error) {\n spin.fail()\n trace.error(error)\n const message = error instanceof Error ? error.message : String(error)\n buildDebug(`Failed to build Sanity Studio`, {error})\n output.error(`Failed to build Sanity Studio: ${message}`, {exit: 1})\n }\n}\n"],"names":["rm","path","styleText","buildDebug","checkStudioDependencyVersions","resolveVendorBuildConfig","StudioBuildTrace","getCliTelemetry","getLocalPackageVersion","getTimer","isInteractive","confirm","logSymbols","select","spinner","parse","semverParse","getAppId","compareDependencyVersions","determineIsApp","formatModuleSizes","sortModulesBySize","getPackageManagerChoice","upgradePackages","warnAboutMissingAppId","buildStaticFiles","checkRequiredDependencies","determineBasePath","getAutoUpdatesCssUrls","getAutoUpdatesImportMap","getStudioEnvironmentVariables","handlePrereleaseVersions","buildStudio","options","calledFromDeploy","cliConfig","flags","outDir","output","workDir","upgradePkgs","packageManager","interactive","chosen","packages","internalBuildStudio","appId","autoUpdatesEnabled","isApp","minify","Boolean","projectId","api","reactCompiler","schemaExtraction","sourceMap","stats","unattendedMode","yes","vite","timer","defaultOutputDir","resolve","join","outputDir","installedSanityVersion","autoUpdatesImports","autoUpdatesCssUrls","cleanSanityVersion","version","Error","log","info","appType","installedVisionVersion","cleanVisionVersion","undefined","sanityDependencies","cssFile","name","mismatched","unresolvedPrerelease","length","versionMismatchWarning","map","mod","pkg","installed","remote","choice","choices","value","default","message","warning","error","exit","res","warn","envVarKeys","Object","keys","key","shouldClean","basePath","enabled","spin","start","force","recursive","cleanDuration","end","text","toFixed","succeed","trace","autoUpdates","cssUrls","imports","vendor","cwd","bundle","outputSize","chunks","flatMap","chunk","modules","renderedLength","reduce","sum","n","buildDuration","complete","slice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0C,cAAc,GACpEC,MAAM,CAAC,CAACC,KAAKC,IAAMD,MAAMC,GAAG;QACjC;QACA,MAAMC,gBAAgBvE,MAAMmD,GAAG,CAAC;QAEhCL,KAAKM,IAAI,GAAG,CAAC,qBAAqB,EAAEmB,cAAclB,OAAO,CAAC,GAAG,GAAG,CAAC;QACjEP,KAAKQ,OAAO;QAEZC,MAAMiB,QAAQ;QACd,IAAI5E,OAAO;YACTlB,OAAOiC,GAAG,CAAC;YACXjC,OAAOiC,GAAG,CAACnD,kBAAkBC,kBAAkBoG,OAAOE,MAAM,EAAEU,KAAK,CAAC,GAAG;QACzE;IACF,EAAE,OAAOtC,OAAO;QACdW,KAAK4B,IAAI;QACTnB,MAAMpB,KAAK,CAACA;QACZ,MAAMF,UAAUE,iBAAiBzB,QAAQyB,MAAMF,OAAO,GAAG0C,OAAOxC;QAChE5F,WAAW,CAAC,6BAA6B,CAAC,EAAE;YAAC4F;QAAK;QAClDzD,OAAOyD,KAAK,CAAC,CAAC,+BAA+B,EAAEF,SAAS,EAAE;YAACG,MAAM;QAAC;IACpE;AACF"}
|
package/oclif.manifest.json
CHANGED
|
@@ -4850,26 +4850,26 @@
|
|
|
4850
4850
|
"unlink.js"
|
|
4851
4851
|
]
|
|
4852
4852
|
},
|
|
4853
|
-
"datasets:
|
|
4853
|
+
"datasets:visibility:get": {
|
|
4854
4854
|
"aliases": [],
|
|
4855
4855
|
"args": {
|
|
4856
4856
|
"dataset": {
|
|
4857
|
-
"description": "
|
|
4857
|
+
"description": "The name of the dataset to get visibility for",
|
|
4858
4858
|
"name": "dataset",
|
|
4859
|
-
"required":
|
|
4859
|
+
"required": true
|
|
4860
4860
|
}
|
|
4861
4861
|
},
|
|
4862
|
-
"description": "
|
|
4862
|
+
"description": "Get the visibility of a dataset",
|
|
4863
4863
|
"examples": [
|
|
4864
4864
|
{
|
|
4865
|
-
"command": "<%= config.bin %> <%= command.id %>
|
|
4866
|
-
"description": "
|
|
4865
|
+
"command": "<%= config.bin %> <%= command.id %> my-dataset",
|
|
4866
|
+
"description": "Check the visibility of a dataset"
|
|
4867
4867
|
}
|
|
4868
4868
|
],
|
|
4869
4869
|
"flags": {
|
|
4870
4870
|
"project-id": {
|
|
4871
4871
|
"char": "p",
|
|
4872
|
-
"description": "Project ID to
|
|
4872
|
+
"description": "Project ID to get dataset visibility for (overrides CLI configuration)",
|
|
4873
4873
|
"helpGroup": "OVERRIDE",
|
|
4874
4874
|
"name": "project-id",
|
|
4875
4875
|
"hasDynamicHelp": false,
|
|
@@ -4880,9 +4880,9 @@
|
|
|
4880
4880
|
},
|
|
4881
4881
|
"hasDynamicHelp": false,
|
|
4882
4882
|
"hiddenAliases": [
|
|
4883
|
-
"dataset:
|
|
4883
|
+
"dataset:visibility:get"
|
|
4884
4884
|
],
|
|
4885
|
-
"id": "datasets:
|
|
4885
|
+
"id": "datasets:visibility:get",
|
|
4886
4886
|
"pluginAlias": "@sanity/cli",
|
|
4887
4887
|
"pluginName": "@sanity/cli",
|
|
4888
4888
|
"pluginType": "core",
|
|
@@ -4892,65 +4892,56 @@
|
|
|
4892
4892
|
"dist",
|
|
4893
4893
|
"commands",
|
|
4894
4894
|
"datasets",
|
|
4895
|
-
"
|
|
4896
|
-
"
|
|
4895
|
+
"visibility",
|
|
4896
|
+
"get.js"
|
|
4897
4897
|
]
|
|
4898
4898
|
},
|
|
4899
|
-
"datasets:
|
|
4899
|
+
"datasets:visibility:set": {
|
|
4900
4900
|
"aliases": [],
|
|
4901
4901
|
"args": {
|
|
4902
4902
|
"dataset": {
|
|
4903
|
-
"description": "
|
|
4903
|
+
"description": "The name of the dataset to set visibility for",
|
|
4904
4904
|
"name": "dataset",
|
|
4905
|
-
"required":
|
|
4905
|
+
"required": true
|
|
4906
|
+
},
|
|
4907
|
+
"mode": {
|
|
4908
|
+
"description": "The visibility mode to set",
|
|
4909
|
+
"name": "mode",
|
|
4910
|
+
"options": [
|
|
4911
|
+
"public",
|
|
4912
|
+
"private"
|
|
4913
|
+
],
|
|
4914
|
+
"required": true
|
|
4906
4915
|
}
|
|
4907
4916
|
},
|
|
4908
|
-
"description": "
|
|
4917
|
+
"description": "Set the visibility of a dataset",
|
|
4909
4918
|
"examples": [
|
|
4910
4919
|
{
|
|
4911
|
-
"command": "<%= config.bin %> <%= command.id %>
|
|
4912
|
-
"description": "
|
|
4913
|
-
},
|
|
4914
|
-
{
|
|
4915
|
-
"command": "<%= config.bin %> <%= command.id %> production --projection \"{ title, body }\"",
|
|
4916
|
-
"description": "Enable embeddings with a specific projection"
|
|
4920
|
+
"command": "<%= config.bin %> <%= command.id %> my-dataset private",
|
|
4921
|
+
"description": "Make a dataset private"
|
|
4917
4922
|
},
|
|
4918
4923
|
{
|
|
4919
|
-
"command": "<%= config.bin %> <%= command.id %>
|
|
4920
|
-
"description": "
|
|
4924
|
+
"command": "<%= config.bin %> <%= command.id %> my-dataset public",
|
|
4925
|
+
"description": "Make a dataset public"
|
|
4921
4926
|
}
|
|
4922
4927
|
],
|
|
4923
4928
|
"flags": {
|
|
4924
4929
|
"project-id": {
|
|
4925
4930
|
"char": "p",
|
|
4926
|
-
"description": "Project ID to
|
|
4931
|
+
"description": "Project ID to set dataset visibility for (overrides CLI configuration)",
|
|
4927
4932
|
"helpGroup": "OVERRIDE",
|
|
4928
4933
|
"name": "project-id",
|
|
4929
4934
|
"hasDynamicHelp": false,
|
|
4930
4935
|
"helpValue": "<id>",
|
|
4931
4936
|
"multiple": false,
|
|
4932
4937
|
"type": "option"
|
|
4933
|
-
},
|
|
4934
|
-
"projection": {
|
|
4935
|
-
"description": "GROQ projection defining which fields to embed (e.g. \"{ title, body }\")",
|
|
4936
|
-
"name": "projection",
|
|
4937
|
-
"required": false,
|
|
4938
|
-
"hasDynamicHelp": false,
|
|
4939
|
-
"multiple": false,
|
|
4940
|
-
"type": "option"
|
|
4941
|
-
},
|
|
4942
|
-
"wait": {
|
|
4943
|
-
"description": "Wait for embeddings processing to complete before returning",
|
|
4944
|
-
"name": "wait",
|
|
4945
|
-
"allowNo": false,
|
|
4946
|
-
"type": "boolean"
|
|
4947
4938
|
}
|
|
4948
4939
|
},
|
|
4949
4940
|
"hasDynamicHelp": false,
|
|
4950
4941
|
"hiddenAliases": [
|
|
4951
|
-
"dataset:
|
|
4942
|
+
"dataset:visibility:set"
|
|
4952
4943
|
],
|
|
4953
|
-
"id": "datasets:
|
|
4944
|
+
"id": "datasets:visibility:set",
|
|
4954
4945
|
"pluginAlias": "@sanity/cli",
|
|
4955
4946
|
"pluginName": "@sanity/cli",
|
|
4956
4947
|
"pluginType": "core",
|
|
@@ -4960,30 +4951,30 @@
|
|
|
4960
4951
|
"dist",
|
|
4961
4952
|
"commands",
|
|
4962
4953
|
"datasets",
|
|
4963
|
-
"
|
|
4964
|
-
"
|
|
4954
|
+
"visibility",
|
|
4955
|
+
"set.js"
|
|
4965
4956
|
]
|
|
4966
4957
|
},
|
|
4967
|
-
"datasets:embeddings:
|
|
4958
|
+
"datasets:embeddings:disable": {
|
|
4968
4959
|
"aliases": [],
|
|
4969
4960
|
"args": {
|
|
4970
4961
|
"dataset": {
|
|
4971
|
-
"description": "
|
|
4962
|
+
"description": "Dataset name to disable embeddings for",
|
|
4972
4963
|
"name": "dataset",
|
|
4973
4964
|
"required": false
|
|
4974
4965
|
}
|
|
4975
4966
|
},
|
|
4976
|
-
"description": "
|
|
4967
|
+
"description": "Disable embeddings for a dataset",
|
|
4977
4968
|
"examples": [
|
|
4978
4969
|
{
|
|
4979
4970
|
"command": "<%= config.bin %> <%= command.id %> production",
|
|
4980
|
-
"description": "
|
|
4971
|
+
"description": "Disable embeddings for the production dataset"
|
|
4981
4972
|
}
|
|
4982
4973
|
],
|
|
4983
4974
|
"flags": {
|
|
4984
4975
|
"project-id": {
|
|
4985
4976
|
"char": "p",
|
|
4986
|
-
"description": "Project ID to
|
|
4977
|
+
"description": "Project ID to disable embeddings for (overrides CLI configuration)",
|
|
4987
4978
|
"helpGroup": "OVERRIDE",
|
|
4988
4979
|
"name": "project-id",
|
|
4989
4980
|
"hasDynamicHelp": false,
|
|
@@ -4994,9 +4985,9 @@
|
|
|
4994
4985
|
},
|
|
4995
4986
|
"hasDynamicHelp": false,
|
|
4996
4987
|
"hiddenAliases": [
|
|
4997
|
-
"dataset:embeddings:
|
|
4988
|
+
"dataset:embeddings:disable"
|
|
4998
4989
|
],
|
|
4999
|
-
"id": "datasets:embeddings:
|
|
4990
|
+
"id": "datasets:embeddings:disable",
|
|
5000
4991
|
"pluginAlias": "@sanity/cli",
|
|
5001
4992
|
"pluginName": "@sanity/cli",
|
|
5002
4993
|
"pluginType": "core",
|
|
@@ -5007,42 +4998,64 @@
|
|
|
5007
4998
|
"commands",
|
|
5008
4999
|
"datasets",
|
|
5009
5000
|
"embeddings",
|
|
5010
|
-
"
|
|
5001
|
+
"disable.js"
|
|
5011
5002
|
]
|
|
5012
5003
|
},
|
|
5013
|
-
"datasets:
|
|
5004
|
+
"datasets:embeddings:enable": {
|
|
5014
5005
|
"aliases": [],
|
|
5015
5006
|
"args": {
|
|
5016
5007
|
"dataset": {
|
|
5017
|
-
"description": "
|
|
5008
|
+
"description": "Dataset name to enable embeddings for",
|
|
5018
5009
|
"name": "dataset",
|
|
5019
|
-
"required":
|
|
5010
|
+
"required": false
|
|
5020
5011
|
}
|
|
5021
5012
|
},
|
|
5022
|
-
"description": "
|
|
5013
|
+
"description": "Enable embeddings for a dataset",
|
|
5023
5014
|
"examples": [
|
|
5024
5015
|
{
|
|
5025
|
-
"command": "<%= config.bin %> <%= command.id %>
|
|
5026
|
-
"description": "
|
|
5016
|
+
"command": "<%= config.bin %> <%= command.id %> production",
|
|
5017
|
+
"description": "Enable embeddings for the production dataset"
|
|
5018
|
+
},
|
|
5019
|
+
{
|
|
5020
|
+
"command": "<%= config.bin %> <%= command.id %> production --projection \"{ title, body }\"",
|
|
5021
|
+
"description": "Enable embeddings with a specific projection"
|
|
5022
|
+
},
|
|
5023
|
+
{
|
|
5024
|
+
"command": "<%= config.bin %> <%= command.id %> production --wait",
|
|
5025
|
+
"description": "Enable embeddings and wait for processing to complete"
|
|
5027
5026
|
}
|
|
5028
5027
|
],
|
|
5029
5028
|
"flags": {
|
|
5030
5029
|
"project-id": {
|
|
5031
5030
|
"char": "p",
|
|
5032
|
-
"description": "Project ID to
|
|
5031
|
+
"description": "Project ID to enable embeddings for (overrides CLI configuration)",
|
|
5033
5032
|
"helpGroup": "OVERRIDE",
|
|
5034
5033
|
"name": "project-id",
|
|
5035
5034
|
"hasDynamicHelp": false,
|
|
5036
5035
|
"helpValue": "<id>",
|
|
5037
5036
|
"multiple": false,
|
|
5038
5037
|
"type": "option"
|
|
5038
|
+
},
|
|
5039
|
+
"projection": {
|
|
5040
|
+
"description": "GROQ projection defining which fields to embed (e.g. \"{ title, body }\")",
|
|
5041
|
+
"name": "projection",
|
|
5042
|
+
"required": false,
|
|
5043
|
+
"hasDynamicHelp": false,
|
|
5044
|
+
"multiple": false,
|
|
5045
|
+
"type": "option"
|
|
5046
|
+
},
|
|
5047
|
+
"wait": {
|
|
5048
|
+
"description": "Wait for embeddings processing to complete before returning",
|
|
5049
|
+
"name": "wait",
|
|
5050
|
+
"allowNo": false,
|
|
5051
|
+
"type": "boolean"
|
|
5039
5052
|
}
|
|
5040
5053
|
},
|
|
5041
5054
|
"hasDynamicHelp": false,
|
|
5042
5055
|
"hiddenAliases": [
|
|
5043
|
-
"dataset:
|
|
5056
|
+
"dataset:embeddings:enable"
|
|
5044
5057
|
],
|
|
5045
|
-
"id": "datasets:
|
|
5058
|
+
"id": "datasets:embeddings:enable",
|
|
5046
5059
|
"pluginAlias": "@sanity/cli",
|
|
5047
5060
|
"pluginName": "@sanity/cli",
|
|
5048
5061
|
"pluginType": "core",
|
|
@@ -5052,43 +5065,30 @@
|
|
|
5052
5065
|
"dist",
|
|
5053
5066
|
"commands",
|
|
5054
5067
|
"datasets",
|
|
5055
|
-
"
|
|
5056
|
-
"
|
|
5068
|
+
"embeddings",
|
|
5069
|
+
"enable.js"
|
|
5057
5070
|
]
|
|
5058
5071
|
},
|
|
5059
|
-
"datasets:
|
|
5072
|
+
"datasets:embeddings:status": {
|
|
5060
5073
|
"aliases": [],
|
|
5061
5074
|
"args": {
|
|
5062
5075
|
"dataset": {
|
|
5063
|
-
"description": "The name of the dataset to
|
|
5076
|
+
"description": "The name of the dataset to check embeddings status for",
|
|
5064
5077
|
"name": "dataset",
|
|
5065
|
-
"required":
|
|
5066
|
-
},
|
|
5067
|
-
"mode": {
|
|
5068
|
-
"description": "The visibility mode to set",
|
|
5069
|
-
"name": "mode",
|
|
5070
|
-
"options": [
|
|
5071
|
-
"public",
|
|
5072
|
-
"private"
|
|
5073
|
-
],
|
|
5074
|
-
"required": true
|
|
5078
|
+
"required": false
|
|
5075
5079
|
}
|
|
5076
5080
|
},
|
|
5077
|
-
"description": "
|
|
5081
|
+
"description": "Show embeddings settings and status for a dataset",
|
|
5078
5082
|
"examples": [
|
|
5079
5083
|
{
|
|
5080
|
-
"command": "<%= config.bin %> <%= command.id %>
|
|
5081
|
-
"description": "
|
|
5082
|
-
},
|
|
5083
|
-
{
|
|
5084
|
-
"command": "<%= config.bin %> <%= command.id %> my-dataset public",
|
|
5085
|
-
"description": "Make a dataset public"
|
|
5084
|
+
"command": "<%= config.bin %> <%= command.id %> production",
|
|
5085
|
+
"description": "Show embeddings status for the production dataset"
|
|
5086
5086
|
}
|
|
5087
5087
|
],
|
|
5088
5088
|
"flags": {
|
|
5089
5089
|
"project-id": {
|
|
5090
5090
|
"char": "p",
|
|
5091
|
-
"description": "Project ID to
|
|
5091
|
+
"description": "Project ID to check embeddings status for (overrides CLI configuration)",
|
|
5092
5092
|
"helpGroup": "OVERRIDE",
|
|
5093
5093
|
"name": "project-id",
|
|
5094
5094
|
"hasDynamicHelp": false,
|
|
@@ -5099,9 +5099,9 @@
|
|
|
5099
5099
|
},
|
|
5100
5100
|
"hasDynamicHelp": false,
|
|
5101
5101
|
"hiddenAliases": [
|
|
5102
|
-
"dataset:
|
|
5102
|
+
"dataset:embeddings:status"
|
|
5103
5103
|
],
|
|
5104
|
-
"id": "datasets:
|
|
5104
|
+
"id": "datasets:embeddings:status",
|
|
5105
5105
|
"pluginAlias": "@sanity/cli",
|
|
5106
5106
|
"pluginName": "@sanity/cli",
|
|
5107
5107
|
"pluginType": "core",
|
|
@@ -5111,10 +5111,10 @@
|
|
|
5111
5111
|
"dist",
|
|
5112
5112
|
"commands",
|
|
5113
5113
|
"datasets",
|
|
5114
|
-
"
|
|
5115
|
-
"
|
|
5114
|
+
"embeddings",
|
|
5115
|
+
"status.js"
|
|
5116
5116
|
]
|
|
5117
5117
|
}
|
|
5118
5118
|
},
|
|
5119
|
-
"version": "7.2.
|
|
5119
|
+
"version": "7.2.2"
|
|
5120
5120
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/cli",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.2",
|
|
4
4
|
"description": "Sanity CLI tool for managing Sanity projects and organizations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"which": "^6.0.1",
|
|
115
115
|
"yaml": "^2.9.0",
|
|
116
116
|
"zod": "^4.4.3",
|
|
117
|
-
"@sanity/cli-build": "^1.0.
|
|
117
|
+
"@sanity/cli-build": "^1.0.4",
|
|
118
118
|
"@sanity/cli-core": "^2.0.1"
|
|
119
119
|
},
|
|
120
120
|
"devDependencies": {
|
|
@@ -139,6 +139,7 @@
|
|
|
139
139
|
"@types/which": "^3.0.4",
|
|
140
140
|
"@vitest/coverage-istanbul": "^4.1.8",
|
|
141
141
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
142
|
+
"es-module-lexer": "^2.1.0",
|
|
142
143
|
"eslint": "^10.4.1",
|
|
143
144
|
"jsdom": "^29.1.1",
|
|
144
145
|
"nock": "^14.0.15",
|
|
@@ -148,9 +149,9 @@
|
|
|
148
149
|
"sanity": "^5.31.1",
|
|
149
150
|
"typescript": "^5.9.3",
|
|
150
151
|
"vitest": "^4.1.8",
|
|
152
|
+
"@repo/package.config": "0.0.1",
|
|
151
153
|
"@repo/tsconfig": "3.70.0",
|
|
152
154
|
"@sanity/cli-test": "1.0.1",
|
|
153
|
-
"@repo/package.config": "0.0.1",
|
|
154
155
|
"@sanity/eslint-config-cli": "1.1.2"
|
|
155
156
|
},
|
|
156
157
|
"peerDependencies": {
|