sanity 3.91.1-next.23.8af6f8d288 → 3.91.1-next.25.19ebe8f22f

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.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var path = require("node:path"), chalk = require("chalk"), logSymbols = require("log-symbols"), semver = require("semver"), telemetry = require("@sanity/telemetry"), rimraf = require("rimraf"), previewServer = require("./previewServer.js");
3
3
  require("./runtime.js");
4
- var upgradePackages = require("./upgradePackages.js"), timing = require("./timing.js"), moduleFormatUtils = require("./moduleFormatUtils.js"), shouldAutoUpdate = require("./shouldAutoUpdate.js");
4
+ var upgradePackages = require("./upgradePackages.js"), timing = require("./timing.js"), moduleFormatUtils = require("./moduleFormatUtils.js"), shouldAutoUpdate = require("./shouldAutoUpdate.js"), _internal = require("./_internal.js");
5
5
  function _interopDefaultCompat(e) {
6
6
  return e && typeof e == "object" && "default" in e ? e : { default: e };
7
7
  }
@@ -44,44 +44,50 @@ async function buildSanityStudio(args, context, overrides) {
44
44
  if (autoUpdatesEnabled) {
45
45
  output.print(`${logSymbols.info} Building with auto-updates enabled`);
46
46
  const result = await shouldAutoUpdate.compareDependencyVersions(autoUpdatesImports, workDir);
47
- if (result?.length && !unattendedMode) {
48
- const choice = await prompt.single({
49
- type: "list",
50
- message: chalk__default.default.yellow(`The following local package versions are different from the versions currently served at runtime.
47
+ if (result?.length) {
48
+ const warning = `The following local package versions are different from the versions currently served at runtime.
51
49
  When using auto updates, we recommend that you test locally with the same versions before deploying.
52
50
 
53
51
  ${result.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join(`
54
52
  `)}
55
53
 
54
+ `;
55
+ if (_internal.isInteractive && !unattendedMode) {
56
+ const choice = await prompt.single({
57
+ type: "list",
58
+ message: chalk__default.default.yellow(`${warning}
59
+
56
60
  Do you want to upgrade local versions before deploying?`),
57
- choices: [{
58
- type: "choice",
59
- value: "upgrade-and-proceed",
60
- name: `Upgrade and proceed with ${args.groupOrCommand}`
61
- }, {
62
- type: "choice",
63
- value: "upgrade",
64
- name: `Upgrade only. You will need to run the ${args.groupOrCommand} command again`
65
- }, {
66
- type: "choice",
67
- name: "Cancel",
68
- value: "cancel"
69
- }],
70
- default: "upgrade-and-proceed"
71
- });
72
- if (choice === "cancel")
73
- return {
74
- didCompile: !1
75
- };
76
- if ((choice === "upgrade" || choice === "upgrade-and-proceed") && (await upgradePackages.upgradePackages({
77
- packageManager: (await upgradePackages.getPackageManagerChoice(workDir, {
78
- interactive: !1
79
- })).chosen,
80
- packages: result.map((res) => [res.pkg, res.remote])
81
- }, context), choice !== "upgrade-and-proceed"))
82
- return {
83
- didCompile: !1
84
- };
61
+ choices: [{
62
+ type: "choice",
63
+ value: "upgrade",
64
+ name: `Upgrade local versions (recommended). You will need to run the ${args.groupOrCommand} command again`
65
+ }, {
66
+ type: "choice",
67
+ value: "upgrade-and-proceed",
68
+ name: `Upgrade and proceed with ${args.groupOrCommand}`
69
+ }, {
70
+ type: "choice",
71
+ name: "Cancel",
72
+ value: "cancel"
73
+ }],
74
+ default: "upgrade-and-proceed"
75
+ });
76
+ if (choice === "cancel")
77
+ return {
78
+ didCompile: !1
79
+ };
80
+ if ((choice === "upgrade" || choice === "upgrade-and-proceed") && (await upgradePackages.upgradePackages({
81
+ packageManager: (await upgradePackages.getPackageManagerChoice(workDir, {
82
+ interactive: !1
83
+ })).chosen,
84
+ packages: result.map((res) => [res.pkg, res.remote])
85
+ }, context), choice !== "upgrade-and-proceed"))
86
+ return {
87
+ didCompile: !1
88
+ };
89
+ } else
90
+ console.warn(`WARNING: ${warning}`);
85
91
  }
86
92
  }
87
93
  const envVarKeys = getSanityEnvVars();
@@ -1 +1 @@
1
- {"version":3,"file":"buildAction2.js","sources":["../../src/_internal/cli/actions/build/build.telemetry.ts","../../src/_internal/cli/actions/build/buildAction.ts"],"sourcesContent":["import {defineTrace} from '@sanity/telemetry'\n\nexport const BuildTrace = defineTrace<{outputSize: number}>({\n name: 'Studio Build Completed',\n version: 0,\n description: 'A Studio build completed',\n})\n","import path from 'node:path'\n\nimport chalk from 'chalk'\nimport {info} from 'log-symbols'\nimport semver from 'semver'\nimport {noopLogger} from '@sanity/telemetry'\nimport {rimraf} from 'rimraf'\nimport type {CliCommandArguments, CliCommandContext} from '@sanity/cli'\n\nimport {buildStaticFiles} from '../../server'\nimport {checkStudioDependencyVersions} from '../../util/checkStudioDependencyVersions'\nimport {checkRequiredDependencies} from '../../util/checkRequiredDependencies'\nimport {getTimer} from '../../util/timing'\nimport {BuildTrace} from './build.telemetry'\nimport {buildVendorDependencies} from '../../server/buildVendorDependencies'\nimport {compareDependencyVersions} from '../../util/compareDependencyVersions'\nimport {getStudioAutoUpdateImportMap} from '../../util/getAutoUpdatesImportMap'\nimport {shouldAutoUpdate} from '../../util/shouldAutoUpdate'\nimport {formatModuleSizes, sortModulesBySize} from '../../util/moduleFormatUtils'\nimport {upgradePackages} from '../../util/packageManager/upgradePackages'\nimport {getPackageManagerChoice} from '../../util/packageManager/packageManagerChoice'\n\nexport interface BuildSanityStudioCommandFlags {\n 'yes'?: boolean\n 'y'?: boolean\n 'minify'?: boolean\n 'stats'?: boolean\n 'source-maps'?: boolean\n 'auto-updates'?: boolean\n}\n\nexport default async function buildSanityStudio(\n args: CliCommandArguments<BuildSanityStudioCommandFlags>,\n context: CliCommandContext,\n overrides?: {basePath?: string},\n): Promise<{didCompile: boolean}> {\n const timer = getTimer()\n const {output, prompt, workDir, cliConfig, telemetry = noopLogger} = context\n const flags: BuildSanityStudioCommandFlags = {\n 'minify': true,\n 'stats': false,\n 'source-maps': false,\n ...args.extOptions,\n }\n\n /**\n * Unattended mode means that if there are any prompts it will use `YES` for them but will no change anything that doesn't have a prompt\n */\n const unattendedMode = Boolean(flags.yes || flags.y)\n const defaultOutputDir = path.resolve(path.join(workDir, 'dist'))\n const outputDir = path.resolve(args.argsWithoutOptions[0] || defaultOutputDir)\n\n await checkStudioDependencyVersions(workDir)\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 {didInstall, installedSanityVersion} = await checkRequiredDependencies(context)\n if (didInstall) {\n return {didCompile: false}\n }\n\n const autoUpdatesEnabled = shouldAutoUpdate({flags, cliConfig, output})\n\n // Get the version without any tags if any\n const coercedSanityVersion = semver.coerce(installedSanityVersion)?.version\n if (autoUpdatesEnabled && !coercedSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n const version = encodeURIComponent(`^${coercedSanityVersion}`)\n const autoUpdatesImports = getStudioAutoUpdateImportMap(version)\n\n if (autoUpdatesEnabled) {\n output.print(`${info} Building with auto-updates enabled`)\n\n // Check the versions\n const result = await compareDependencyVersions(autoUpdatesImports, workDir)\n\n // If it is in unattended mode, we don't want to prompt\n if (result?.length && !unattendedMode) {\n const choice = await prompt.single({\n type: 'list',\n message: chalk.yellow(\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 `${result.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')} \\n\\n` +\n `Do you want to upgrade local versions before deploying?`,\n ),\n choices: [\n {\n type: 'choice',\n value: 'upgrade-and-proceed',\n name: `Upgrade and proceed with ${args.groupOrCommand}`,\n },\n {\n type: 'choice',\n value: 'upgrade',\n name: `Upgrade only. You will need to run the ${args.groupOrCommand} command again`,\n },\n {type: 'choice', name: 'Cancel', value: 'cancel'},\n ],\n default: 'upgrade-and-proceed',\n })\n\n if (choice === 'cancel') {\n return {didCompile: false}\n }\n\n if (choice === 'upgrade' || choice === 'upgrade-and-proceed') {\n await upgradePackages(\n {\n packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,\n packages: result.map((res) => [res.pkg, res.remote]),\n },\n context,\n )\n\n if (choice !== 'upgrade-and-proceed') {\n return {didCompile: false}\n }\n }\n }\n }\n\n const envVarKeys = getSanityEnvVars()\n if (envVarKeys.length > 0) {\n output.print(\n '\\nIncluding the following environment variables as part of the JavaScript bundle:',\n )\n envVarKeys.forEach((key) => output.print(`- ${key}`))\n output.print('')\n }\n\n let shouldClean = true\n if (outputDir !== defaultOutputDir && !unattendedMode) {\n shouldClean = await prompt.single({\n type: 'confirm',\n message: `Do you want to delete the existing directory (${outputDir}) first?`,\n default: true,\n })\n }\n\n // Determine base path for built studio\n let basePath = '/'\n const envBasePath = process.env.SANITY_STUDIO_BASEPATH\n const configBasePath = cliConfig?.project?.basePath\n\n // Allow `sanity deploy` to override base path\n if (overrides?.basePath) {\n basePath = overrides.basePath\n } else if (envBasePath) {\n // Environment variable (SANITY_STUDIO_BASEPATH)\n basePath = envBasePath\n } else if (configBasePath) {\n // `sanity.cli.ts`\n basePath = configBasePath\n }\n\n if (envBasePath && configBasePath) {\n output.warn(\n `Overriding configured base path (${configBasePath}) with value from environment variable (${envBasePath})`,\n )\n }\n\n let spin\n\n if (shouldClean) {\n timer.start('cleanOutputFolder')\n spin = output.spinner('Clean output folder').start()\n await rimraf(outputDir)\n const cleanDuration = timer.end('cleanOutputFolder')\n spin.text = `Clean output folder (${cleanDuration.toFixed()}ms)`\n spin.succeed()\n }\n\n spin = output.spinner(`Build Sanity Studio`).start()\n\n const trace = telemetry.trace(BuildTrace)\n trace.start()\n\n let importMap\n\n if (autoUpdatesEnabled) {\n importMap = {\n imports: {\n ...(await buildVendorDependencies({cwd: workDir, outputDir, basePath})),\n ...autoUpdatesImports,\n },\n }\n }\n\n try {\n timer.start('bundleStudio')\n\n const bundle = await buildStaticFiles({\n cwd: workDir,\n outputDir,\n basePath,\n sourceMap: Boolean(flags['source-maps']),\n minify: Boolean(flags.minify),\n vite: cliConfig && 'vite' in cliConfig ? cliConfig.vite : undefined,\n importMap,\n reactCompiler:\n cliConfig && 'reactCompiler' in cliConfig ? cliConfig.reactCompiler : undefined,\n entry: cliConfig && 'app' in cliConfig ? cliConfig.app?.entry : undefined,\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()}ms)`\n spin.succeed()\n\n trace.complete()\n if (flags.stats) {\n output.print('\\nLargest module files:')\n output.print(formatModuleSizes(sortModulesBySize(bundle.chunks).slice(0, 15)))\n }\n } catch (err) {\n spin.fail()\n trace.error(err)\n throw err\n }\n\n return {didCompile: true}\n}\n\n// eslint-disable-next-line no-process-env\nfunction getSanityEnvVars(env: Record<string, string | undefined> = process.env): string[] {\n return Object.keys(env).filter((key) => key.toUpperCase().startsWith('SANITY_STUDIO_'))\n}\n"],"names":["BuildTrace","defineTrace","name","version","description","buildSanityStudio","args","context","overrides","timer","getTimer","output","prompt","workDir","cliConfig","telemetry","noopLogger","flags","extOptions","unattendedMode","Boolean","yes","y","defaultOutputDir","path","resolve","join","outputDir","argsWithoutOptions","checkStudioDependencyVersions","didInstall","installedSanityVersion","checkRequiredDependencies","didCompile","autoUpdatesEnabled","shouldAutoUpdate","coercedSanityVersion","semver","coerce","Error","encodeURIComponent","autoUpdatesImports","getStudioAutoUpdateImportMap","print","info","result","compareDependencyVersions","length","choice","single","type","message","chalk","yellow","map","mod","pkg","installed","remote","choices","value","groupOrCommand","default","upgradePackages","packageManager","getPackageManagerChoice","interactive","chosen","packages","res","envVarKeys","getSanityEnvVars","forEach","key","shouldClean","basePath","envBasePath","process","env","SANITY_STUDIO_BASEPATH","configBasePath","project","warn","spin","start","spinner","rimraf","cleanDuration","end","text","toFixed","succeed","trace","importMap","imports","buildVendorDependencies","cwd","bundle","buildStaticFiles","sourceMap","minify","vite","undefined","reactCompiler","entry","app","log","outputSize","chunks","flatMap","chunk","modules","renderedLength","reduce","sum","n","buildDuration","complete","stats","formatModuleSizes","sortModulesBySize","slice","err","fail","error","Object","keys","filter","toUpperCase","startsWith"],"mappings":";;;;;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;AAAAA,MACAwB,WAAW/E,CAAQH,CAAAA,MAAM,aAAa;AAAA,MACtCmF,QAAQhF,EAAQH,MAAMmF;AAAAA,MACtBC,MAAMvF,aAAa,UAAUA,YAAYA,UAAUuF,OAAOC;AAAAA,MAC1DT;AAAAA,MACAU,eACEzF,aAAa,mBAAmBA,YAAYA,UAAUyF,gBAAgBD;AAAAA,MACxEE,OAAO1F,aAAa,SAASA,YAAYA,UAAU2F,KAAKD,QAAQF;AAAAA,IAAAA,CACjE;AAEDV,UAAMc,IAAI;AAAA,MACRC,YAAYV,OAAOW,OAChBC,QAASC,CAAUA,UAAAA,MAAMC,QAAQF,QAAStD,CAAAA,QAAQA,IAAIyD,cAAc,CAAC,EACrEC,OAAO,CAACC,KAAKC,MAAMD,MAAMC,GAAG,CAAC;AAAA,IAAA,CACjC;AACKC,UAAAA,gBAAgB3G,MAAM+E,IAAI,cAAc;AAE9CL,SAAKM,OAAO,wBAAwB2B,cAAc1B,QAAAA,CAAS,OAC3DP,KAAKQ,QAAQ,GAEbC,MAAMyB,SAAS,GACXpG,MAAMqG,UACR3G,OAAOgC,MAAM;AAAA,sBAAyB,GACtChC,OAAOgC,MAAM4E,kBAAAA,kBAAkBC,kBAAAA,kBAAkBvB,OAAOW,MAAM,EAAEa,MAAM,GAAG,EAAE,CAAC,CAAC;AAAA,WAExEC,KAAK;AACZvC,UAAAA,KAAKwC,KAAK,GACV/B,MAAMgC,MAAMF,GAAG,GACTA;AAAAA,EAAAA;AAGD,SAAA;AAAA,IAACzF,YAAY;AAAA,EAAI;AAC1B;AAGA,SAASsC,iBAAiBO,MAA0CD,QAAQC,KAAe;AAClF+C,SAAAA,OAAOC,KAAKhD,GAAG,EAAEiD,OAAQtD,CAAQA,QAAAA,IAAIuD,YAAY,EAAEC,WAAW,gBAAgB,CAAC;AACxF;;"}
1
+ {"version":3,"file":"buildAction2.js","sources":["../../src/_internal/cli/actions/build/build.telemetry.ts","../../src/_internal/cli/actions/build/buildAction.ts"],"sourcesContent":["import {defineTrace} from '@sanity/telemetry'\n\nexport const BuildTrace = defineTrace<{outputSize: number}>({\n name: 'Studio Build Completed',\n version: 0,\n description: 'A Studio build completed',\n})\n","import path from 'node:path'\n\nimport chalk from 'chalk'\nimport {info} from 'log-symbols'\nimport semver from 'semver'\nimport {noopLogger} from '@sanity/telemetry'\nimport {rimraf} from 'rimraf'\nimport type {CliCommandArguments, CliCommandContext} from '@sanity/cli'\n\nimport {buildStaticFiles} from '../../server'\nimport {checkStudioDependencyVersions} from '../../util/checkStudioDependencyVersions'\nimport {checkRequiredDependencies} from '../../util/checkRequiredDependencies'\nimport {getTimer} from '../../util/timing'\nimport {BuildTrace} from './build.telemetry'\nimport {buildVendorDependencies} from '../../server/buildVendorDependencies'\nimport {compareDependencyVersions} from '../../util/compareDependencyVersions'\nimport {getStudioAutoUpdateImportMap} from '../../util/getAutoUpdatesImportMap'\nimport {shouldAutoUpdate} from '../../util/shouldAutoUpdate'\nimport {formatModuleSizes, sortModulesBySize} from '../../util/moduleFormatUtils'\nimport {upgradePackages} from '../../util/packageManager/upgradePackages'\nimport {getPackageManagerChoice} from '../../util/packageManager/packageManagerChoice'\nimport {isInteractive} from '../../util/isInteractive'\n\nexport interface BuildSanityStudioCommandFlags {\n 'yes'?: boolean\n 'y'?: boolean\n 'minify'?: boolean\n 'stats'?: boolean\n 'source-maps'?: boolean\n 'auto-updates'?: boolean\n}\n\nexport default async function buildSanityStudio(\n args: CliCommandArguments<BuildSanityStudioCommandFlags>,\n context: CliCommandContext,\n overrides?: {basePath?: string},\n): Promise<{didCompile: boolean}> {\n const timer = getTimer()\n const {output, prompt, workDir, cliConfig, telemetry = noopLogger} = context\n const flags: BuildSanityStudioCommandFlags = {\n 'minify': true,\n 'stats': false,\n 'source-maps': false,\n ...args.extOptions,\n }\n\n /**\n * Unattended mode means that if there are any prompts it will use `YES` for them but will no change anything that doesn't have a prompt\n */\n const unattendedMode = Boolean(flags.yes || flags.y)\n const defaultOutputDir = path.resolve(path.join(workDir, 'dist'))\n const outputDir = path.resolve(args.argsWithoutOptions[0] || defaultOutputDir)\n\n await checkStudioDependencyVersions(workDir)\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 {didInstall, installedSanityVersion} = await checkRequiredDependencies(context)\n if (didInstall) {\n return {didCompile: false}\n }\n\n const autoUpdatesEnabled = shouldAutoUpdate({flags, cliConfig, output})\n\n // Get the version without any tags if any\n const coercedSanityVersion = semver.coerce(installedSanityVersion)?.version\n if (autoUpdatesEnabled && !coercedSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n const version = encodeURIComponent(`^${coercedSanityVersion}`)\n const autoUpdatesImports = getStudioAutoUpdateImportMap(version)\n\n if (autoUpdatesEnabled) {\n output.print(`${info} Building with auto-updates enabled`)\n\n // Check the versions\n const result = await compareDependencyVersions(autoUpdatesImports, workDir)\n\n if (result?.length) {\n const warning =\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 `${result.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')} \\n\\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 prompt.single({\n type: 'list',\n message: chalk.yellow(\n `${warning}\\n\\nDo you want to upgrade local versions before deploying?`,\n ),\n choices: [\n {\n type: 'choice',\n value: 'upgrade',\n name: `Upgrade local versions (recommended). You will need to run the ${args.groupOrCommand} command again`,\n },\n {\n type: 'choice',\n value: 'upgrade-and-proceed',\n name: `Upgrade and proceed with ${args.groupOrCommand}`,\n },\n {type: 'choice', name: 'Cancel', value: 'cancel'},\n ],\n default: 'upgrade-and-proceed',\n })\n\n if (choice === 'cancel') {\n return {didCompile: false}\n }\n\n if (choice === 'upgrade' || choice === 'upgrade-and-proceed') {\n await upgradePackages(\n {\n packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,\n packages: result.map((res) => [res.pkg, res.remote]),\n },\n context,\n )\n\n if (choice !== 'upgrade-and-proceed') {\n return {didCompile: false}\n }\n }\n } else {\n // if non-interactive or unattended, just show the warning\n console.warn(`WARNING: ${warning}`)\n }\n }\n }\n\n const envVarKeys = getSanityEnvVars()\n if (envVarKeys.length > 0) {\n output.print(\n '\\nIncluding the following environment variables as part of the JavaScript bundle:',\n )\n envVarKeys.forEach((key) => output.print(`- ${key}`))\n output.print('')\n }\n\n let shouldClean = true\n if (outputDir !== defaultOutputDir && !unattendedMode) {\n shouldClean = await prompt.single({\n type: 'confirm',\n message: `Do you want to delete the existing directory (${outputDir}) first?`,\n default: true,\n })\n }\n\n // Determine base path for built studio\n let basePath = '/'\n const envBasePath = process.env.SANITY_STUDIO_BASEPATH\n const configBasePath = cliConfig?.project?.basePath\n\n // Allow `sanity deploy` to override base path\n if (overrides?.basePath) {\n basePath = overrides.basePath\n } else if (envBasePath) {\n // Environment variable (SANITY_STUDIO_BASEPATH)\n basePath = envBasePath\n } else if (configBasePath) {\n // `sanity.cli.ts`\n basePath = configBasePath\n }\n\n if (envBasePath && configBasePath) {\n output.warn(\n `Overriding configured base path (${configBasePath}) with value from environment variable (${envBasePath})`,\n )\n }\n\n let spin\n\n if (shouldClean) {\n timer.start('cleanOutputFolder')\n spin = output.spinner('Clean output folder').start()\n await rimraf(outputDir)\n const cleanDuration = timer.end('cleanOutputFolder')\n spin.text = `Clean output folder (${cleanDuration.toFixed()}ms)`\n spin.succeed()\n }\n\n spin = output.spinner(`Build Sanity Studio`).start()\n\n const trace = telemetry.trace(BuildTrace)\n trace.start()\n\n let importMap\n\n if (autoUpdatesEnabled) {\n importMap = {\n imports: {\n ...(await buildVendorDependencies({cwd: workDir, outputDir, basePath})),\n ...autoUpdatesImports,\n },\n }\n }\n\n try {\n timer.start('bundleStudio')\n\n const bundle = await buildStaticFiles({\n cwd: workDir,\n outputDir,\n basePath,\n sourceMap: Boolean(flags['source-maps']),\n minify: Boolean(flags.minify),\n vite: cliConfig && 'vite' in cliConfig ? cliConfig.vite : undefined,\n importMap,\n reactCompiler:\n cliConfig && 'reactCompiler' in cliConfig ? cliConfig.reactCompiler : undefined,\n entry: cliConfig && 'app' in cliConfig ? cliConfig.app?.entry : undefined,\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()}ms)`\n spin.succeed()\n\n trace.complete()\n if (flags.stats) {\n output.print('\\nLargest module files:')\n output.print(formatModuleSizes(sortModulesBySize(bundle.chunks).slice(0, 15)))\n }\n } catch (err) {\n spin.fail()\n trace.error(err)\n throw err\n }\n\n return {didCompile: true}\n}\n\n// eslint-disable-next-line no-process-env\nfunction getSanityEnvVars(env: Record<string, string | undefined> = process.env): string[] {\n return Object.keys(env).filter((key) => key.toUpperCase().startsWith('SANITY_STUDIO_'))\n}\n"],"names":["BuildTrace","defineTrace","name","version","description","buildSanityStudio","args","context","overrides","timer","getTimer","output","prompt","workDir","cliConfig","telemetry","noopLogger","flags","extOptions","unattendedMode","Boolean","yes","y","defaultOutputDir","path","resolve","join","outputDir","argsWithoutOptions","checkStudioDependencyVersions","didInstall","installedSanityVersion","checkRequiredDependencies","didCompile","autoUpdatesEnabled","shouldAutoUpdate","coercedSanityVersion","semver","coerce","Error","encodeURIComponent","autoUpdatesImports","getStudioAutoUpdateImportMap","print","info","result","compareDependencyVersions","length","warning","map","mod","pkg","installed","remote","isInteractive","choice","single","type","message","chalk","yellow","choices","value","groupOrCommand","default","upgradePackages","packageManager","getPackageManagerChoice","interactive","chosen","packages","res","warn","envVarKeys","getSanityEnvVars","forEach","key","shouldClean","basePath","envBasePath","process","env","SANITY_STUDIO_BASEPATH","configBasePath","project","spin","start","spinner","rimraf","cleanDuration","end","text","toFixed","succeed","trace","importMap","imports","buildVendorDependencies","cwd","bundle","buildStaticFiles","sourceMap","minify","vite","undefined","reactCompiler","entry","app","log","outputSize","chunks","flatMap","chunk","modules","renderedLength","reduce","sum","n","buildDuration","complete","stats","formatModuleSizes","sortModulesBySize","slice","err","fail","error","Object","keys","filter","toUpperCase","startsWith"],"mappings":";;;;;;;;AAEO,MAAMA,aAAaC,UAAAA,YAAkC;AAAA,EAC1DC,MAAM;AAAA,EACNC,SAAS;AAAA,EACTC,aAAa;AACf,CAAC;AC0B6BC,eAAAA,kBAC5BC,MACAC,SACAC,WACgC;AAC1BC,QAAAA,QAAQC,OAAAA,YACR;AAAA,IAACC;AAAAA,IAAQC;AAAAA,IAAQC;AAAAA,IAASC;AAAAA,IAAAA,WAAWC,cAAYC,UAAAA;AAAAA,EAAAA,IAAcT,SAC/DU,QAAuC;AAAA,IAC3C,QAAU;AAAA,IACV,OAAS;AAAA,IACT,eAAe;AAAA,IACf,GAAGX,KAAKY;AAAAA,EACV,GAKMC,iBAAiBC,CAAQH,EAAAA,MAAMI,OAAOJ,MAAMK,IAC5CC,mBAAmBC,sBAAKC,QAAQD,cAAAA,QAAKE,KAAKb,SAAS,MAAM,CAAC,GAC1Dc,YAAYH,cAAAA,QAAKC,QAAQnB,KAAKsB,mBAAmB,CAAC,KAAKL,gBAAgB;AAE7E,QAAMM,gBAAAA,8BAA8BhB,OAAO;AAIrC,QAAA;AAAA,IAACiB;AAAAA,IAAYC;AAAAA,EAAAA,IAA0B,MAAMC,gBAAAA,0BAA0BzB,OAAO;AAChFuB,MAAAA;AACK,WAAA;AAAA,MAACG,YAAY;AAAA,IAAK;AAG3B,QAAMC,qBAAqBC,iBAAAA,iBAAiB;AAAA,IAAClB;AAAAA,IAAOH;AAAAA,IAAWH;AAAAA,EAAO,CAAA,GAGhEyB,uBAAuBC,gBAAAA,QAAOC,OAAOP,sBAAsB,GAAG5B;AACpE,MAAI+B,sBAAsB,CAACE;AACzB,UAAM,IAAIG,MAAM,6CAA6CR,sBAAsB,EAAE;AAE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G,GACTA;AAAAA,EAAAA;AAGD,SAAA;AAAA,IAAC3F,YAAY;AAAA,EAAI;AAC1B;AAGA,SAASyC,iBAAiBO,MAA0CD,QAAQC,KAAe;AAClF8C,SAAAA,OAAOC,KAAK/C,GAAG,EAAEgD,OAAQrD,CAAQA,QAAAA,IAAIsD,YAAY,EAAEC,WAAW,gBAAgB,CAAC;AACxF;;"}
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
- const SANITY_VERSION = "3.91.1-next.23.8af6f8d288";
2
+ const SANITY_VERSION = "3.91.1-next.25.19ebe8f22f";
3
3
  exports.SANITY_VERSION = SANITY_VERSION;
4
4
  //# sourceMappingURL=version.js.map
@@ -1,4 +1,4 @@
1
- const SANITY_VERSION = "3.91.1-next.23.8af6f8d288";
1
+ const SANITY_VERSION = "3.91.1-next.25.19ebe8f22f";
2
2
  export {
3
3
  SANITY_VERSION
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanity",
3
- "version": "3.91.1-next.23.8af6f8d288",
3
+ "version": "3.91.1-next.25.19ebe8f22f",
4
4
  "description": "Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches",
5
5
  "keywords": [
6
6
  "sanity",
@@ -156,11 +156,11 @@
156
156
  "@rexxars/react-json-inspector": "^9.0.1",
157
157
  "@sanity/asset-utils": "^2.0.6",
158
158
  "@sanity/bifur-client": "^0.4.1",
159
- "@sanity/cli": "3.91.1-next.23.8af6f8d288",
159
+ "@sanity/cli": "3.91.1-next.25.19ebe8f22f",
160
160
  "@sanity/client": "^7.4.1",
161
161
  "@sanity/color": "^3.0.0",
162
162
  "@sanity/comlink": "^3.0.5",
163
- "@sanity/diff": "3.91.1-next.23.8af6f8d288",
163
+ "@sanity/diff": "3.91.1-next.25.19ebe8f22f",
164
164
  "@sanity/diff-match-patch": "^3.1.1",
165
165
  "@sanity/diff-patch": "^5.0.0",
166
166
  "@sanity/eventsource": "^5.0.0",
@@ -172,16 +172,16 @@
172
172
  "@sanity/insert-menu": "^1.1.12",
173
173
  "@sanity/logos": "^2.2.0",
174
174
  "@sanity/message-protocol": "^0.13.0",
175
- "@sanity/migrate": "3.91.1-next.23.8af6f8d288",
176
- "@sanity/mutator": "3.91.1-next.23.8af6f8d288",
175
+ "@sanity/migrate": "3.91.1-next.25.19ebe8f22f",
176
+ "@sanity/mutator": "3.91.1-next.25.19ebe8f22f",
177
177
  "@sanity/presentation-comlink": "^1.0.21",
178
178
  "@sanity/preview-url-secret": "^2.1.11",
179
- "@sanity/schema": "3.91.1-next.23.8af6f8d288",
179
+ "@sanity/schema": "3.91.1-next.25.19ebe8f22f",
180
180
  "@sanity/sdk": "0.0.0-alpha.25",
181
181
  "@sanity/telemetry": "^0.8.0",
182
- "@sanity/types": "3.91.1-next.23.8af6f8d288",
182
+ "@sanity/types": "3.91.1-next.25.19ebe8f22f",
183
183
  "@sanity/ui": "^2.15.18",
184
- "@sanity/util": "3.91.1-next.23.8af6f8d288",
184
+ "@sanity/util": "3.91.1-next.25.19ebe8f22f",
185
185
  "@sanity/uuid": "^3.0.2",
186
186
  "@sentry/react": "^8.33.0",
187
187
  "@tanstack/react-table": "^8.16.0",
@@ -288,7 +288,7 @@
288
288
  "@repo/dev-aliases": "3.91.0",
289
289
  "@repo/package.config": "3.91.0",
290
290
  "@repo/test-config": "3.91.0",
291
- "@sanity/codegen": "3.91.1-next.23.8af6f8d288",
291
+ "@sanity/codegen": "3.91.1-next.25.19ebe8f22f",
292
292
  "@sanity/generate-help-url": "^3.0.0",
293
293
  "@sanity/pkg-utils": "6.13.4",
294
294
  "@sanity/tsdoc": "1.0.169",
@@ -335,5 +335,5 @@
335
335
  "engines": {
336
336
  "node": ">=18"
337
337
  },
338
- "gitHead": "8af6f8d288d3ddc1d9a60f4b1430a33e48b18fdb"
338
+ "gitHead": "19ebe8f22fecc7afc327d40c9579e1ad31191305"
339
339
  }
@@ -19,6 +19,7 @@ import {shouldAutoUpdate} from '../../util/shouldAutoUpdate'
19
19
  import {formatModuleSizes, sortModulesBySize} from '../../util/moduleFormatUtils'
20
20
  import {upgradePackages} from '../../util/packageManager/upgradePackages'
21
21
  import {getPackageManagerChoice} from '../../util/packageManager/packageManagerChoice'
22
+ import {isInteractive} from '../../util/isInteractive'
22
23
 
23
24
  export interface BuildSanityStudioCommandFlags {
24
25
  'yes'?: boolean
@@ -75,48 +76,55 @@ export default async function buildSanityStudio(
75
76
  // Check the versions
76
77
  const result = await compareDependencyVersions(autoUpdatesImports, workDir)
77
78
 
78
- // If it is in unattended mode, we don't want to prompt
79
- if (result?.length && !unattendedMode) {
80
- const choice = await prompt.single({
81
- type: 'list',
82
- message: chalk.yellow(
83
- `The following local package versions are different from the versions currently served at runtime.\n` +
84
- `When using auto updates, we recommend that you test locally with the same versions before deploying. \n\n` +
85
- `${result.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\n')} \n\n` +
86
- `Do you want to upgrade local versions before deploying?`,
87
- ),
88
- choices: [
89
- {
90
- type: 'choice',
91
- value: 'upgrade-and-proceed',
92
- name: `Upgrade and proceed with ${args.groupOrCommand}`,
93
- },
94
- {
95
- type: 'choice',
96
- value: 'upgrade',
97
- name: `Upgrade only. You will need to run the ${args.groupOrCommand} command again`,
98
- },
99
- {type: 'choice', name: 'Cancel', value: 'cancel'},
100
- ],
101
- default: 'upgrade-and-proceed',
102
- })
103
-
104
- if (choice === 'cancel') {
105
- return {didCompile: false}
106
- }
107
-
108
- if (choice === 'upgrade' || choice === 'upgrade-and-proceed') {
109
- await upgradePackages(
110
- {
111
- packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,
112
- packages: result.map((res) => [res.pkg, res.remote]),
113
- },
114
- context,
115
- )
116
-
117
- if (choice !== 'upgrade-and-proceed') {
79
+ if (result?.length) {
80
+ const warning =
81
+ `The following local package versions are different from the versions currently served at runtime.\n` +
82
+ `When using auto updates, we recommend that you test locally with the same versions before deploying. \n\n` +
83
+ `${result.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\n')} \n\n`
84
+
85
+ // If it is non-interactive or in unattended mode, we don't want to prompt
86
+ if (isInteractive && !unattendedMode) {
87
+ const choice = await prompt.single({
88
+ type: 'list',
89
+ message: chalk.yellow(
90
+ `${warning}\n\nDo you want to upgrade local versions before deploying?`,
91
+ ),
92
+ choices: [
93
+ {
94
+ type: 'choice',
95
+ value: 'upgrade',
96
+ name: `Upgrade local versions (recommended). You will need to run the ${args.groupOrCommand} command again`,
97
+ },
98
+ {
99
+ type: 'choice',
100
+ value: 'upgrade-and-proceed',
101
+ name: `Upgrade and proceed with ${args.groupOrCommand}`,
102
+ },
103
+ {type: 'choice', name: 'Cancel', value: 'cancel'},
104
+ ],
105
+ default: 'upgrade-and-proceed',
106
+ })
107
+
108
+ if (choice === 'cancel') {
118
109
  return {didCompile: false}
119
110
  }
111
+
112
+ if (choice === 'upgrade' || choice === 'upgrade-and-proceed') {
113
+ await upgradePackages(
114
+ {
115
+ packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,
116
+ packages: result.map((res) => [res.pkg, res.remote]),
117
+ },
118
+ context,
119
+ )
120
+
121
+ if (choice !== 'upgrade-and-proceed') {
122
+ return {didCompile: false}
123
+ }
124
+ }
125
+ } else {
126
+ // if non-interactive or unattended, just show the warning
127
+ console.warn(`WARNING: ${warning}`)
120
128
  }
121
129
  }
122
130
  }