sanity 4.9.0-next.16 → 4.9.0-next.19

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"), telemetry = require("@sanity/telemetry"), chalk = require("chalk"), logSymbols = require("log-symbols"), rimraf = require("rimraf"), semver = require("semver"), previewServer = require("./previewServer.js");
3
3
  require("./runtime.js");
4
- var moduleFormatUtils = require("./moduleFormatUtils.js"), shouldAutoUpdate = require("./shouldAutoUpdate.js"), timing = require("./timing.js");
4
+ var moduleFormatUtils = require("./moduleFormatUtils.js"), warnAboutMissingAppId = require("./warnAboutMissingAppId.js"), getAppId = require("./getAppId.js"), timing = require("./timing.js");
5
5
  function _interopDefaultCompat(e) {
6
6
  return e && typeof e == "object" && "default" in e ? e : { default: e };
7
7
  }
@@ -17,16 +17,20 @@ async function buildSanityApp(args, context, overrides) {
17
17
  prompt,
18
18
  workDir,
19
19
  cliConfig,
20
- telemetry: telemetry$1 = telemetry.noopLogger
20
+ telemetry: telemetry$1 = telemetry.noopLogger,
21
+ cliConfigPath
21
22
  } = context, flags = {
22
23
  minify: !0,
23
24
  stats: !1,
24
25
  "source-maps": !1,
25
26
  ...args.extOptions
26
- }, unattendedMode = !!(flags.yes || flags.y), defaultOutputDir = path__default.default.resolve(path__default.default.join(workDir, "dist")), outputDir = path__default.default.resolve(args.argsWithoutOptions[0] || defaultOutputDir), autoUpdatesEnabled = shouldAutoUpdate.shouldAutoUpdate({
27
+ }, unattendedMode = !!(flags.yes || flags.y), defaultOutputDir = path__default.default.resolve(path__default.default.join(workDir, "dist")), outputDir = path__default.default.resolve(args.argsWithoutOptions[0] || defaultOutputDir), autoUpdatesEnabled = warnAboutMissingAppId.shouldAutoUpdate({
27
28
  flags,
28
29
  cliConfig
29
- }), installedSdkVersion = await shouldAutoUpdate.readModuleVersion(context.workDir, "@sanity/sdk-react"), installedSanityVersion = await shouldAutoUpdate.readModuleVersion(context.workDir, "sanity");
30
+ }), appId = getAppId.getAppId({
31
+ cliConfig,
32
+ output
33
+ }), installedSdkVersion = await warnAboutMissingAppId.readModuleVersion(context.workDir, "@sanity/sdk-react"), installedSanityVersion = await warnAboutMissingAppId.readModuleVersion(context.workDir, "sanity");
30
34
  if (!installedSdkVersion)
31
35
  throw new Error("Failed to find installed @sanity/sdk-react version");
32
36
  let autoUpdatesImports = {};
@@ -44,8 +48,15 @@ async function buildSanityApp(args, context, overrides) {
44
48
  name: "sanity",
45
49
  version: cleanSanityVersion
46
50
  }] : []];
47
- autoUpdatesImports = shouldAutoUpdate.getAutoUpdatesImportMap(autoUpdatedPackages), output.print(`${logSymbols.info} Building with auto-updates enabled`);
48
- const result = await shouldAutoUpdate.compareDependencyVersions(autoUpdatedPackages, workDir);
51
+ autoUpdatesImports = warnAboutMissingAppId.getAutoUpdatesImportMap(autoUpdatedPackages, {
52
+ appId
53
+ }), output.print(`${logSymbols.info} Building with auto-updates enabled`), args.groupOrCommand !== "deploy" && !appId && warnAboutMissingAppId.warnAboutMissingAppId({
54
+ appType: "app",
55
+ cliConfigPath,
56
+ output,
57
+ projectId: cliConfig?.api?.projectId
58
+ });
59
+ const result = await warnAboutMissingAppId.compareDependencyVersions(autoUpdatedPackages, workDir, {});
49
60
  if (result?.length && !unattendedMode && !await prompt.single({
50
61
  type: "confirm",
51
62
  message: chalk__default.default.yellow(`The following local package versions are different from the versions currently served at runtime.
@@ -1 +1 @@
1
- {"version":3,"file":"buildAction.js","sources":["../../src/_internal/cli/actions/app/build.telemetry.ts","../../src/_internal/cli/actions/app/buildAction.ts"],"sourcesContent":["import {defineTrace} from '@sanity/telemetry'\n\nexport const BuildTrace = defineTrace<{outputSize: number}>({\n name: 'App Build Completed',\n version: 0,\n description: 'An App build completed',\n})\n","/* eslint-disable max-statements */\nimport path from 'node:path'\n\nimport {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\nimport {noopLogger} from '@sanity/telemetry'\nimport chalk from 'chalk'\nimport {info} from 'log-symbols'\nimport {rimraf} from 'rimraf'\nimport semver from 'semver'\n\nimport {buildStaticFiles} from '../../server'\nimport {buildVendorDependencies} from '../../server/buildVendorDependencies'\nimport {compareDependencyVersions} from '../../util/compareDependencyVersions'\nimport {getAutoUpdatesImportMap} from '../../util/getAutoUpdatesImportMap'\nimport {formatModuleSizes, sortModulesBySize} from '../../util/moduleFormatUtils'\nimport {readModuleVersion} from '../../util/readModuleVersion'\nimport {shouldAutoUpdate} from '../../util/shouldAutoUpdate'\nimport {getTimer} from '../../util/timing'\nimport {BuildTrace} from './build.telemetry'\n\nexport interface BuildSanityAppCommandFlags {\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 buildSanityApp(\n args: CliCommandArguments<BuildSanityAppCommandFlags>,\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: BuildSanityAppCommandFlags = {\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 const autoUpdatesEnabled = shouldAutoUpdate({flags, cliConfig})\n\n const installedSdkVersion = await readModuleVersion(context.workDir, '@sanity/sdk-react')\n const installedSanityVersion = await readModuleVersion(context.workDir, 'sanity')\n\n if (!installedSdkVersion) {\n throw new Error(`Failed to find installed @sanity/sdk-react version`)\n }\n\n let autoUpdatesImports = {}\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSDKVersion = semver.parse(installedSdkVersion)?.version\n if (!cleanSDKVersion) {\n throw new Error(`Failed to parse installed SDK version: ${installedSdkVersion}`)\n }\n\n // Sanity might not be installed, but if it is, we want to auto update it.\n const cleanSanityVersion = semver.parse(installedSanityVersion)?.version\n\n const autoUpdatedPackages = [\n {name: '@sanity/sdk', version: cleanSDKVersion},\n {name: '@sanity/sdk-react', version: cleanSDKVersion},\n ...(cleanSanityVersion ? [{name: 'sanity' as const, version: cleanSanityVersion}] : []),\n ]\n autoUpdatesImports = getAutoUpdatesImportMap(autoUpdatedPackages)\n output.print(`${info} Building with auto-updates enabled`)\n\n // Check the versions\n const result = await compareDependencyVersions(autoUpdatedPackages, workDir)\n\n // If it is in unattended mode, we don't want to prompt\n if (result?.length && !unattendedMode) {\n const shouldContinue = await prompt.single({\n type: 'confirm',\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 `Continue anyway?`,\n ),\n default: false,\n })\n\n if (!shouldContinue) {\n return process.exit(0)\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_APP_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_APP_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 application`).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 isApp: true,\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()}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\nfunction getSanityEnvVars(env: Record<string, string | undefined> = process.env): string[] {\n return Object.keys(env).filter((key) => key.toUpperCase().startsWith('SANITY_APP_'))\n}\n"],"names":["BuildTrace","defineTrace","name","version","description","buildSanityApp","args","context","overrides","timer","getTimer","output","prompt","workDir","cliConfig","telemetry","noopLogger","flags","extOptions","unattendedMode","Boolean","yes","y","defaultOutputDir","path","resolve","join","outputDir","argsWithoutOptions","autoUpdatesEnabled","shouldAutoUpdate","installedSdkVersion","readModuleVersion","installedSanityVersion","Error","autoUpdatesImports","cleanSDKVersion","semver","parse","cleanSanityVersion","autoUpdatedPackages","getAutoUpdatesImportMap","print","info","result","compareDependencyVersions","length","single","type","message","chalk","yellow","map","mod","pkg","installed","remote","default","process","exit","envVarKeys","getSanityEnvVars","forEach","key","shouldClean","basePath","envBasePath","env","SANITY_APP_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","isApp","log","outputSize","chunks","flatMap","chunk","modules","renderedLength","reduce","sum","n","buildDuration","complete","stats","formatModuleSizes","sortModulesBySize","slice","err","fail","error","didCompile","Object","keys","filter","toUpperCase","startsWith"],"mappings":";;;;;;;;AAEO,MAAMA,aAAaC,UAAAA,YAAkC;AAAA,EAC1DC,MAAM;AAAA,EACNC,SAAS;AAAA,EACTC,aAAa;AACf,CAAC;ACuBD,eAA8BC,eAC5BC,MACAC,SACAC,WACgC;AAChC,QAAMC,QAAQC,OAAAA,YACR;AAAA,IAACC;AAAAA,IAAQC;AAAAA,IAAQC;AAAAA,IAASC;AAAAA,IAAAA,WAAWC,cAAYC,UAAAA;AAAAA,EAAAA,IAAcT,SAC/DU,QAAoC;AAAA,IACxC,QAAU;AAAA,IACV,OAAS;AAAA,IACT,eAAe;AAAA,IACf,GAAGX,KAAKY;AAAAA,EAAAA,GAMJC,iBAAiBC,CAAAA,EAAQH,MAAMI,OAAOJ,MAAMK,IAC5CC,mBAAmBC,cAAAA,QAAKC,QAAQD,cAAAA,QAAKE,KAAKb,SAAS,MAAM,CAAC,GAC1Dc,YAAYH,cAAAA,QAAKC,QAAQnB,KAAK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CT,QAAQS,KAAe;AACzF,SAAOiD,OAAOC,KAAKlD,GAAG,EAAEmD,OAAQvD,CAAAA,QAAQA,IAAIwD,YAAAA,EAAcC,WAAW,aAAa,CAAC;AACrF;;"}
1
+ {"version":3,"file":"buildAction.js","sources":["../../src/_internal/cli/actions/app/build.telemetry.ts","../../src/_internal/cli/actions/app/buildAction.ts"],"sourcesContent":["import {defineTrace} from '@sanity/telemetry'\n\nexport const BuildTrace = defineTrace<{outputSize: number}>({\n name: 'App Build Completed',\n version: 0,\n description: 'An App build completed',\n})\n","/* eslint-disable max-statements */\nimport path from 'node:path'\n\nimport {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\nimport {noopLogger} from '@sanity/telemetry'\nimport chalk from 'chalk'\nimport {info} from 'log-symbols'\nimport {rimraf} from 'rimraf'\nimport semver from 'semver'\n\nimport {buildStaticFiles} from '../../server'\nimport {buildVendorDependencies} from '../../server/buildVendorDependencies'\nimport {compareDependencyVersions} from '../../util/compareDependencyVersions'\nimport {getAppId} from '../../util/getAppId'\nimport {getAutoUpdatesImportMap} from '../../util/getAutoUpdatesImportMap'\nimport {formatModuleSizes, sortModulesBySize} from '../../util/moduleFormatUtils'\nimport {readModuleVersion} from '../../util/readModuleVersion'\nimport {shouldAutoUpdate} from '../../util/shouldAutoUpdate'\nimport {getTimer} from '../../util/timing'\nimport {warnAboutMissingAppId} from '../../util/warnAboutMissingAppId'\nimport {BuildTrace} from './build.telemetry'\n\nexport interface BuildSanityAppCommandFlags {\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 buildSanityApp(\n args: CliCommandArguments<BuildSanityAppCommandFlags>,\n context: CliCommandContext,\n overrides?: {basePath?: string},\n): Promise<{didCompile: boolean}> {\n const timer = getTimer()\n const {output, prompt, workDir, cliConfig, telemetry = noopLogger, cliConfigPath} = context\n const flags: BuildSanityAppCommandFlags = {\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 const autoUpdatesEnabled = shouldAutoUpdate({flags, cliConfig})\n const appId = getAppId({cliConfig, output})\n\n const installedSdkVersion = await readModuleVersion(context.workDir, '@sanity/sdk-react')\n const installedSanityVersion = await readModuleVersion(context.workDir, 'sanity')\n\n if (!installedSdkVersion) {\n throw new Error(`Failed to find installed @sanity/sdk-react version`)\n }\n\n let autoUpdatesImports = {}\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSDKVersion = semver.parse(installedSdkVersion)?.version\n if (!cleanSDKVersion) {\n throw new Error(`Failed to parse installed SDK version: ${installedSdkVersion}`)\n }\n\n // Sanity might not be installed, but if it is, we want to auto update it.\n const cleanSanityVersion = semver.parse(installedSanityVersion)?.version\n\n const autoUpdatedPackages = [\n {name: '@sanity/sdk', version: cleanSDKVersion},\n {name: '@sanity/sdk-react', version: cleanSDKVersion},\n ...(cleanSanityVersion ? [{name: 'sanity' as const, version: cleanSanityVersion}] : []),\n ]\n autoUpdatesImports = getAutoUpdatesImportMap(autoUpdatedPackages, {appId})\n output.print(`${info} Building with auto-updates enabled`)\n\n // note: we want to show this warning only if running `sanity build`\n // since `sanity deploy` will prompt for appId if it's missing and tell the user to add it to sanity.cli.ts when done\n // see deployAction.ts\n if (args.groupOrCommand !== 'deploy' && !appId) {\n warnAboutMissingAppId({\n appType: 'app',\n cliConfigPath,\n output,\n projectId: cliConfig?.api?.projectId,\n })\n }\n\n // Check the versions\n const result = await compareDependencyVersions(autoUpdatedPackages, workDir, {appId})\n\n // If it is in unattended mode, we don't want to prompt\n if (result?.length && !unattendedMode) {\n const shouldContinue = await prompt.single({\n type: 'confirm',\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 `Continue anyway?`,\n ),\n default: false,\n })\n\n if (!shouldContinue) {\n return process.exit(0)\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_APP_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_APP_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 application`).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 isApp: true,\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()}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\nfunction getSanityEnvVars(env: Record<string, string | undefined> = process.env): string[] {\n return Object.keys(env).filter((key) => key.toUpperCase().startsWith('SANITY_APP_'))\n}\n"],"names":["BuildTrace","defineTrace","name","version","description","buildSanityApp","args","context","overrides","timer","getTimer","output","prompt","workDir","cliConfig","telemetry","noopLogger","cliConfigPath","flags","extOptions","unattendedMode","Boolean","yes","y","defaultOutputDir","path","resolve","join","outputDir","argsWithoutOptions","autoUpdatesEnabled","shouldAutoUpdate","appId","getAppId","installedSdkVersion","readModuleVersion","installedSanityVersion","Error","autoUpdatesImports","cleanSDKVersion","semver","parse","cleanSanityVersion","autoUpdatedPackages","getAutoUpdatesImportMap","print","info","groupOrCommand","warnAboutMissingAppId","appType","projectId","api","result","compareDependencyVersions","length","single","type","message","chalk","yellow","map","mod","pkg","installed","remote","default","process","exit","envVarKeys","getSanityEnvVars","forEach","key","shouldClean","basePath","envBasePath","env","SANITY_APP_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","isApp","log","outputSize","chunks","flatMap","chunk","modules","renderedLength","reduce","sum","n","buildDuration","complete","stats","formatModuleSizes","sortModulesBySize","slice","err","fail","error","didCompile","Object","keys","filter","toUpperCase","startsWith"],"mappings":";;;;;;;;AAEO,MAAMA,aAAaC,UAAAA,YAAkC;AAAA,EAC1DC,MAAM;AAAA,EACNC,SAAS;AAAA,EACTC,aAAa;AACf,CAAC;ACyBD,eAA8BC,eAC5BC,MACAC,SACAC,WACgC;AAChC,QAAMC,QAAQC,OAAAA,YACR;AAAA,IAACC;AAAAA,IAAQC;AAAAA,IAAQC;AAAAA,IAASC;AAAAA,IAAAA,WAAWC,cAAYC,UAAAA;AAAAA,IAAYC;AAAAA,EAAAA,IAAiBV,SAC9EW,QAAoC;AAAA,IACxC,QAAU;AAAA,IACV,OAAS;AAAA,IACT,eAAe;AAAA,IACf,GAAGZ,KAAKa;AAAAA,EAAAA,GAMJC,iBAAiBC,CAAAA,EAAQH,MAAMI,OAAOJ,MAAMK,IAC5CC,mBAAmBC,cAAAA,QAAKC,QAAQD,cAAAA,QAAKE,KAAKd,SAAS,MAAM,CAAC,GAC1De,YAAYH,cAAAA,QAAKC,QAAQpB,KAAKuB,mBAAmB,CAAC,KAAKL,gBAAgB,GAEvEM,qBAAqBC,sBAAAA,iBAAiB;AAAA,IAACb;AAAAA,IAAOJ;AAAAA,EAAAA,CAAU,GACxDkB,QAAQC,kBAAS;AAAA,IAACnB;AAAAA,IAAWH;AAAAA,EAAAA,CAAO,GAEpCuB,sBAAsB,MAAMC,wCAAkB5B,QAAQM,SAAS,mBAAmB,GAClFuB,yBAAyB,MAAMD,sBAAAA,kBAAkB5B,QAAQM,SAAS,QAAQ;AAEhF,MAAI,CAACqB;AACH,UAAM,IAAIG,MAAM,oDAAoD;AAGtE,MAAIC,qBAAqB,CAAA;AAEzB,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WAAW,aAAa,CAAC;AACrF;;"}
@@ -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"), _internal = require("./_internal.js");
4
+ var upgradePackages = require("./upgradePackages.js"), timing = require("./timing.js"), moduleFormatUtils = require("./moduleFormatUtils.js"), warnAboutMissingAppId = require("./warnAboutMissingAppId.js"), _internal = require("./_internal.js"), getAppId = require("./getAppId.js");
5
5
  function _interopDefaultCompat(e) {
6
6
  return e && typeof e == "object" && "default" in e ? e : { default: e };
7
7
  }
@@ -17,7 +17,8 @@ async function buildSanityStudio(args, context, overrides) {
17
17
  prompt,
18
18
  workDir,
19
19
  cliConfig,
20
- telemetry: telemetry$1 = telemetry.noopLogger
20
+ telemetry: telemetry$1 = telemetry.noopLogger,
21
+ cliConfigPath
21
22
  } = context, flags = {
22
23
  minify: !0,
23
24
  stats: !1,
@@ -33,7 +34,7 @@ async function buildSanityStudio(args, context, overrides) {
33
34
  return {
34
35
  didCompile: !1
35
36
  };
36
- const autoUpdatesEnabled = shouldAutoUpdate.shouldAutoUpdate({
37
+ const autoUpdatesEnabled = warnAboutMissingAppId.shouldAutoUpdate({
37
38
  flags,
38
39
  cliConfig,
39
40
  output
@@ -49,9 +50,19 @@ async function buildSanityStudio(args, context, overrides) {
49
50
  }, {
50
51
  name: "@sanity/vision",
51
52
  version: cleanSanityVersion
52
- }];
53
- autoUpdatesImports = shouldAutoUpdate.getAutoUpdatesImportMap(sanityDependencies), output.print(`${logSymbols.info} Building with auto-updates enabled`);
54
- const result = await shouldAutoUpdate.compareDependencyVersions(sanityDependencies, workDir);
53
+ }], appId = getAppId.getAppId({
54
+ cliConfig,
55
+ output
56
+ });
57
+ autoUpdatesImports = warnAboutMissingAppId.getAutoUpdatesImportMap(sanityDependencies, {
58
+ appId
59
+ }), output.print(`${logSymbols.info} Building with auto-updates enabled`), args.groupOrCommand !== "deploy" && !appId && warnAboutMissingAppId.warnAboutMissingAppId({
60
+ appType: "studio",
61
+ cliConfigPath,
62
+ output,
63
+ projectId: cliConfig?.api?.projectId
64
+ });
65
+ const result = await warnAboutMissingAppId.compareDependencyVersions(sanityDependencies, workDir);
55
66
  if (result?.length) {
56
67
  const warning = `The following local package versions are different from the versions currently served at runtime.
57
68
  When using auto updates, we recommend that you test locally with the same versions before deploying.
@@ -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 {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'\nimport {getAutoUpdatesImportMap} from '../../util/getAutoUpdatesImportMap'\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 let autoUpdatesImports = {}\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSanityVersion = semver.parse(installedSanityVersion)?.version\n if (!cleanSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n\n const sanityDependencies = [\n {name: 'sanity', version: cleanSanityVersion},\n {name: '@sanity/vision', version: cleanSanityVersion},\n ]\n autoUpdatesImports = getAutoUpdatesImportMap(sanityDependencies)\n\n output.print(`${info} Building with auto-updates enabled`)\n\n // Check the versions\n const result = await compareDependencyVersions(sanityDependencies, 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 {\n type: 'choice',\n value: 'continue',\n name: `Continue anyway`,\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","autoUpdatesImports","cleanSanityVersion","semver","parse","Error","sanityDependencies","getAutoUpdatesImportMap","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","console","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;AC0BD,eAA8BC,kBAC5BC,MACAC,SACAC,WACgC;AAChC,QAAMC,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,EAAAA,GAMJC,iBAAiBC,CAA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AAMsF;AAAAA,MACtBC,MAAM1F,aAAa,UAAUA,YAAYA,UAAU0F,OAAOC;AAAAA,MAC1DT;AAAAA,MACAU,eACE5F,aAAa,mBAAmBA,YAAYA,UAAU4F,gBAAgBD;AAAAA,MACxEE,OAAO7F,aAAa,SAASA,YAAYA,UAAU8F,KAAKD,QAAQF;AAAAA,IAAAA,CACjE;AAEDV,UAAMc,IAAI;AAAA,MACRC,YAAYV,OAAOW,OAChBC,QAASC,CAAAA,UAAUA,MAAMC,QAAQF,QAAS9D,CAAAA,QAAQA,IAAIiE,cAAc,CAAC,EACrEC,OAAO,CAACC,KAAKC,MAAMD,MAAMC,GAAG,CAAC;AAAA,IAAA,CACjC;AACD,UAAMC,gBAAgB9G,MAAMkF,IAAI,cAAc;AAE9CL,SAAKM,OAAO,wBAAwB2B,cAAc1B,QAAAA,CAAS,OAC3DP,KAAKQ,QAAAA,GAELC,MAAMyB,SAAAA,GACFvG,MAAMwG,UACR9G,OAAOgC,MAAM;AAAA,sBAAyB,GACtChC,OAAOgC,MAAM+E,kBAAAA,kBAAkBC,kBAAAA,kBAAkBvB,OAAOW,MAAM,EAAEa,MAAM,GAAG,EAAE,CAAC,CAAC;AAAA,EAEjF,SAASC,KAAK;AACZvC,UAAAA,KAAKwC,KAAAA,GACL/B,MAAMgC,MAAMF,GAAG,GACTA;AAAAA,EACR;AAEA,SAAO;AAAA,IAAC5F,YAAY;AAAA,EAAA;AACtB;AAGA,SAAS0C,iBAAiBO,MAA0CD,QAAQC,KAAe;AACzF,SAAO8C,OAAOC,KAAK/C,GAAG,EAAEgD,OAAQrD,CAAAA,QAAQA,IAAIsD,YAAAA,EAAcC,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, warning} 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 {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'\nimport {getAutoUpdatesImportMap} from '../../util/getAutoUpdatesImportMap'\nimport {getAppId} from '../../util/getAppId'\nimport {baseUrl} from '../../util/baseUrl'\nimport {warnAboutMissingAppId} from '../../util/warnAboutMissingAppId'\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, cliConfigPath} = 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 let autoUpdatesImports = {}\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSanityVersion = semver.parse(installedSanityVersion)?.version\n if (!cleanSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n\n const sanityDependencies = [\n {name: 'sanity', version: cleanSanityVersion},\n {name: '@sanity/vision', version: cleanSanityVersion},\n ]\n\n const appId = getAppId({cliConfig, output})\n\n autoUpdatesImports = getAutoUpdatesImportMap(sanityDependencies, {appId})\n\n output.print(`${info} Building with auto-updates enabled`)\n\n // note: we want to show this warning only if running `sanity build`\n // since `sanity deploy` will prompt for appId if it's missing and tell the user to add it to sanity.cli.ts when done\n // see deployAction.ts\n if (args.groupOrCommand !== 'deploy' && !appId) {\n warnAboutMissingAppId({\n appType: 'studio',\n cliConfigPath,\n output,\n projectId: cliConfig?.api?.projectId,\n })\n }\n\n // Check the versions\n const result = await compareDependencyVersions(sanityDependencies, 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 {\n type: 'choice',\n value: 'continue',\n name: `Continue anyway`,\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","cliConfigPath","flags","extOptions","unattendedMode","Boolean","yes","y","defaultOutputDir","path","resolve","join","outputDir","argsWithoutOptions","checkStudioDependencyVersions","didInstall","installedSanityVersion","checkRequiredDependencies","didCompile","autoUpdatesEnabled","shouldAutoUpdate","autoUpdatesImports","cleanSanityVersion","semver","parse","Error","sanityDependencies","appId","getAppId","getAutoUpdatesImportMap","print","info","groupOrCommand","warnAboutMissingAppId","appType","projectId","api","result","compareDependencyVersions","length","warning","map","mod","pkg","installed","remote","isInteractive","choice","single","type","message","chalk","yellow","choices","value","default","upgradePackages","packageManager","getPackageManagerChoice","interactive","chosen","packages","res","console","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;AC6BD,eAA8BC,kBAC5BC,MACAC,SACAC,WACgC;AAChC,QAAMC,QAAQC,OAAAA,YACR;AAAA,IAACC;AAAAA,IAAQC;AAAAA,IAAQC;AAAAA,IAASC;AAAAA,IAAAA,WAAWC,cAAYC,UAAAA;AAAAA,IAAYC;AAAAA,EAAAA,IAAiBV,SAC9EW,QAAuC;AAAA,IAC3C,QAAU;AAAA,IACV,OAAS;AAAA,IACT,eAAe;AAAA,IACf,GAAGZ,KAAKa;AAAAA,EAAAA,GAMJC,iBAAiBC,CAAAA,EAAQH,MAAMI,OAAOJ,MAAMK,IAC5CC,mBAAmBC,sBAAKC,QAAQD,cAAAA,QAAKE,KAAKd,SAAS,MAAM,CAAC,GAC1De,YAAYH,cAAAA,QAAKC,QAAQpB,KAAKuB,mBAAmB,CAAC,KAAKL,gBAAgB;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fs"), shouldAutoUpdate = require("./shouldAutoUpdate.js"), helpers = require("./helpers.js"), buildAction = require("./buildAction.js");
2
+ var path = require("node:path"), zlib = require("node:zlib"), tar = require("tar-fs"), getAppId = require("./getAppId.js"), warnAboutMissingAppId = require("./warnAboutMissingAppId.js"), helpers = require("./helpers.js"), buildAction = require("./buildAction.js");
3
3
  function _interopDefaultCompat(e) {
4
4
  return e && typeof e == "object" && "default" in e ? e : { default: e };
5
5
  }
@@ -15,10 +15,13 @@ async function deployAppAction(args, context) {
15
15
  } = context, flags = {
16
16
  build: !0,
17
17
  ...args.extOptions
18
- }, customSourceDir = args.argsWithoutOptions[0], sourceDir = path__default.default.resolve(process.cwd(), customSourceDir || path__default.default.join(workDir, "dist")), isAutoUpdating = shouldAutoUpdate.shouldAutoUpdate({
18
+ }, customSourceDir = args.argsWithoutOptions[0], sourceDir = path__default.default.resolve(process.cwd(), customSourceDir || path__default.default.join(workDir, "dist")), isAutoUpdating = warnAboutMissingAppId.shouldAutoUpdate({
19
19
  flags,
20
20
  cliConfig
21
- }), installedSanityVersion = await helpers.getInstalledSanityVersion(), appId = cliConfig && "app" in cliConfig && cliConfig.app?.id, client = apiClient({
21
+ }), installedSanityVersion = await helpers.getInstalledSanityVersion(), appId = getAppId.getAppId({
22
+ cliConfig,
23
+ output
24
+ }), client = apiClient({
22
25
  requireUser: !0,
23
26
  requireProject: !1
24
27
  // custom apps are not project-specific
@@ -47,7 +50,8 @@ async function deployAppAction(args, context) {
47
50
  };
48
51
  appId ? userApplication = await helpers.getOrCreateUserApplicationFromConfig({
49
52
  ...configParams,
50
- appId
53
+ appId,
54
+ appHost: void 0
51
55
  }) : userApplication = await helpers.getOrCreateApplication(configParams);
52
56
  } catch (err) {
53
57
  if (err.message) {
@@ -58,6 +62,7 @@ async function deployAppAction(args, context) {
58
62
  }
59
63
  if (flags.build) {
60
64
  const buildArgs = {
65
+ ...args,
61
66
  extOptions: flags,
62
67
  argsWithoutOptions: [customSourceDir].filter(Boolean)
63
68
  }, {
@@ -79,7 +84,7 @@ async function deployAppAction(args, context) {
79
84
  }).pipe(zlib__default.default.createGzip());
80
85
  spinner = output.spinner("Deploying...").start();
81
86
  try {
82
- await helpers.createDeployment({
87
+ if (await helpers.createDeployment({
83
88
  client,
84
89
  applicationId: userApplication.id,
85
90
  version: installedSanityVersion,
@@ -87,8 +92,19 @@ async function deployAppAction(args, context) {
87
92
  tarball,
88
93
  isApp: !0
89
94
  }), spinner.succeed(), output.print(`
90
- Success! Application deployed`), appId || (output.print(`
91
- Add ${chalk.cyan(`id: '${userApplication.id}'`)}`), output.print("to `app` in sanity.cli.js or sanity.cli.ts"), output.print("to avoid prompting on next deploy."));
95
+ Success! Application deployed`), !appId) {
96
+ const example = `Example:
97
+ export default defineCliConfig({
98
+ //\u2026
99
+ deployment: {
100
+ ${chalk.cyan`appId: '${userApplication.id}'`},
101
+ },
102
+ //\u2026
103
+ })`;
104
+ output.print(`
105
+ Add ${chalk.cyan(`appId: '${userApplication.id}'`)}`), output.print("to the `deployment` section in sanity.cli.js or sanity.cli.ts"), output.print("to avoid prompting for appId on next deploy."), output.print(`
106
+ ${example}`);
107
+ }
92
108
  } catch (err) {
93
109
  throw spinner.fail(), helpers.debug("Error deploying application", err), err;
94
110
  }
@@ -1 +1 @@
1
- {"version":3,"file":"deployAction.js","sources":["../../src/_internal/cli/actions/app/deployAction.ts"],"sourcesContent":["/* eslint-disable max-statements */\nimport path from 'node:path'\nimport zlib from 'node:zlib'\n\nimport {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\nimport tar from 'tar-fs'\n\nimport {shouldAutoUpdate} from '../../util/shouldAutoUpdate'\nimport {\n checkDir,\n createDeployment,\n debug,\n dirIsEmptyOrNonExistent,\n getInstalledSanityVersion,\n getOrCreateApplication,\n getOrCreateUserApplicationFromConfig,\n type UserApplication,\n} from '../deploy/helpers'\nimport buildSanityApp, {type BuildSanityAppCommandFlags} from './buildAction'\n\nexport interface DeployAppActionFlags extends BuildSanityAppCommandFlags {\n build?: boolean\n}\n\nexport default async function deployAppAction(\n args: CliCommandArguments<DeployAppActionFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const {apiClient, workDir, chalk, output, prompt, cliConfig} = context\n const flags = {build: true, ...args.extOptions}\n const customSourceDir = args.argsWithoutOptions[0]\n const sourceDir = path.resolve(process.cwd(), customSourceDir || path.join(workDir, 'dist'))\n // not really required yet, but will be required in the future\n const isAutoUpdating = shouldAutoUpdate({flags, cliConfig})\n\n const installedSanityVersion = await getInstalledSanityVersion()\n const appId = cliConfig && 'app' in cliConfig && cliConfig.app?.id\n\n const client = apiClient({\n requireUser: true,\n requireProject: false, // custom apps are not project-specific\n }).withConfig({apiVersion: 'v2024-08-01'})\n\n if (customSourceDir) {\n let relativeOutput = path.relative(process.cwd(), sourceDir)\n if (relativeOutput[0] !== '.') {\n relativeOutput = `./${relativeOutput}`\n }\n\n const isEmpty = await dirIsEmptyOrNonExistent(sourceDir)\n const shouldProceed =\n isEmpty ||\n (await prompt.single({\n type: 'confirm',\n message: `\"${relativeOutput}\" is not empty, do you want to proceed?`,\n default: false,\n }))\n\n if (!shouldProceed) {\n output.print('Cancelled.')\n return\n }\n\n output.print(`Building to ${relativeOutput}\\n`)\n }\n\n // Check that the project exists\n let spinner = output.spinner('Checking application info').start()\n\n let userApplication: UserApplication\n\n try {\n const configParams = {\n client,\n context,\n spinner,\n }\n\n // If the user has provided an appId in the config, use that\n if (appId) {\n userApplication = await getOrCreateUserApplicationFromConfig({...configParams, appId})\n } else {\n userApplication = await getOrCreateApplication(configParams)\n }\n } catch (err) {\n if (err.message) {\n output.error(chalk.red(err.message))\n return\n }\n\n debug('Error creating user application', err)\n throw err\n }\n\n // Always build the project, unless --no-build is passed\n const shouldBuild = flags.build\n if (shouldBuild) {\n const buildArgs = {\n ...args,\n extOptions: flags,\n argsWithoutOptions: [customSourceDir].filter(Boolean),\n }\n const {didCompile} = await buildSanityApp(buildArgs, context, {basePath: '/'})\n\n if (!didCompile) {\n return\n }\n }\n\n // Ensure that the directory exists, is a directory and seems to have valid content\n spinner = output.spinner('Verifying local content').start()\n try {\n await checkDir(sourceDir)\n spinner.succeed()\n } catch (err) {\n spinner.fail()\n debug('Error checking directory', err)\n throw err\n }\n\n // Now create a tarball of the given directory\n const parentDir = path.dirname(sourceDir)\n const base = path.basename(sourceDir)\n const tarball = tar.pack(parentDir, {entries: [base]}).pipe(zlib.createGzip())\n\n spinner = output.spinner('Deploying...').start()\n try {\n await createDeployment({\n client,\n applicationId: userApplication.id,\n version: installedSanityVersion,\n isAutoUpdating,\n tarball,\n isApp: true,\n })\n\n spinner.succeed()\n\n // And let the user know we're done\n output.print(`\\nSuccess! Application deployed`)\n\n if (!appId) {\n output.print(`\\nAdd ${chalk.cyan(`id: '${userApplication.id}'`)}`)\n output.print('to `app` in sanity.cli.js or sanity.cli.ts')\n output.print(`to avoid prompting on next deploy.`)\n }\n } catch (err) {\n spinner.fail()\n debug('Error deploying application', err)\n throw err\n }\n}\n"],"names":["deployAppAction","args","context","apiClient","workDir","chalk","output","prompt","cliConfig","flags","build","extOptions","customSourceDir","argsWithoutOptions","sourceDir","path","resolve","process","cwd","join","isAutoUpdating","shouldAutoUpdate","installedSanityVersion","getInstalledSanityVersion","appId","app","id","client","requireUser","requireProject","withConfig","apiVersion","relativeOutput","relative","dirIsEmptyOrNonExistent","single","type","message","default","print","spinner","start","userApplication","configParams","getOrCreateUserApplicationFromConfig","getOrCreateApplication","err","error","red","debug","buildArgs","filter","Boolean","didCompile","buildSanityApp","basePath","checkDir","succeed","fail","parentDir","dirname","base","basename","tarball","tar","pack","entries","pipe","zlib","createGzip","createDeployment","applicationId","version","isApp","cyan"],"mappings":";;;;;;AAwBA,eAA8BA,gBAC5BC,MACAC,SACe;AACf,QAAM;AAAA,IAACC;AAAAA,IAAWC;AAAAA,IAASC;AAAAA,IAAOC;AAAAA,IAAQC;AAAAA,IAAQC;AAAAA,EAAAA,IAAaN,SACzDO,QAAQ;AAAA,IAACC,OA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BhB,EAAE,GAAG,CAAC,EAAE,GACjEpB,OAAOiC,MAAM,4CAA4C,GACzDjC,OAAOiC,MAAM,oCAAoC;AAAA,EAErD,SAASO,KAAK;AACZN,UAAAA,QAAQkB,KAAAA,GACRT,QAAAA,MAAM,+BAA+BH,GAAG,GAClCA;AAAAA,EACR;AACF;;"}
1
+ {"version":3,"file":"deployAction.js","sources":["../../src/_internal/cli/actions/app/deployAction.ts"],"sourcesContent":["/* eslint-disable max-statements */\nimport path from 'node:path'\nimport zlib from 'node:zlib'\n\nimport {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\nimport tar from 'tar-fs'\n\nimport {getAppId} from '../../util/getAppId'\nimport {shouldAutoUpdate} from '../../util/shouldAutoUpdate'\nimport {\n checkDir,\n createDeployment,\n debug,\n dirIsEmptyOrNonExistent,\n getInstalledSanityVersion,\n getOrCreateApplication,\n getOrCreateUserApplicationFromConfig,\n type UserApplication,\n} from '../deploy/helpers'\nimport buildSanityApp, {type BuildSanityAppCommandFlags} from './buildAction'\n\nexport interface DeployAppActionFlags extends BuildSanityAppCommandFlags {\n build?: boolean\n}\n\nexport default async function deployAppAction(\n args: CliCommandArguments<DeployAppActionFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const {apiClient, workDir, chalk, output, prompt, cliConfig, cliConfigPath} = context\n const flags = {build: true, ...args.extOptions}\n const customSourceDir = args.argsWithoutOptions[0]\n const sourceDir = path.resolve(process.cwd(), customSourceDir || path.join(workDir, 'dist'))\n // not really required yet, but will be required in the future\n const isAutoUpdating = shouldAutoUpdate({flags, cliConfig})\n\n const installedSanityVersion = await getInstalledSanityVersion()\n const appId = getAppId({cliConfig, output})\n\n const client = apiClient({\n requireUser: true,\n requireProject: false, // custom apps are not project-specific\n }).withConfig({apiVersion: 'v2024-08-01'})\n\n if (customSourceDir) {\n let relativeOutput = path.relative(process.cwd(), sourceDir)\n if (relativeOutput[0] !== '.') {\n relativeOutput = `./${relativeOutput}`\n }\n\n const isEmpty = await dirIsEmptyOrNonExistent(sourceDir)\n const shouldProceed =\n isEmpty ||\n (await prompt.single({\n type: 'confirm',\n message: `\"${relativeOutput}\" is not empty, do you want to proceed?`,\n default: false,\n }))\n\n if (!shouldProceed) {\n output.print('Cancelled.')\n return\n }\n\n output.print(`Building to ${relativeOutput}\\n`)\n }\n\n // Check that the project exists\n let spinner = output.spinner('Checking application info').start()\n\n let userApplication: UserApplication\n\n try {\n const configParams = {\n client,\n context,\n spinner,\n }\n\n // If the user has provided an appId in the config, use that\n if (appId) {\n userApplication = await getOrCreateUserApplicationFromConfig({\n ...configParams,\n appId,\n appHost: undefined,\n })\n } else {\n userApplication = await getOrCreateApplication(configParams)\n }\n } catch (err) {\n if (err.message) {\n output.error(chalk.red(err.message))\n return\n }\n\n debug('Error creating user application', err)\n throw err\n }\n\n // Always build the project, unless --no-build is passed\n const shouldBuild = flags.build\n if (shouldBuild) {\n const buildArgs = {\n ...args,\n extOptions: flags,\n argsWithoutOptions: [customSourceDir].filter(Boolean),\n }\n const {didCompile} = await buildSanityApp(buildArgs, context, {basePath: '/'})\n\n if (!didCompile) {\n return\n }\n }\n\n // Ensure that the directory exists, is a directory and seems to have valid content\n spinner = output.spinner('Verifying local content').start()\n try {\n await checkDir(sourceDir)\n spinner.succeed()\n } catch (err) {\n spinner.fail()\n debug('Error checking directory', err)\n throw err\n }\n\n // Now create a tarball of the given directory\n const parentDir = path.dirname(sourceDir)\n const base = path.basename(sourceDir)\n const tarball = tar.pack(parentDir, {entries: [base]}).pipe(zlib.createGzip())\n\n spinner = output.spinner('Deploying...').start()\n try {\n await createDeployment({\n client,\n applicationId: userApplication.id,\n version: installedSanityVersion,\n isAutoUpdating,\n tarball,\n isApp: true,\n })\n\n spinner.succeed()\n\n // And let the user know we're done\n output.print(`\\nSuccess! Application deployed`)\n\n if (!appId) {\n const example = `Example:\nexport default defineCliConfig({\n //…\n deployment: {\n ${chalk.cyan`appId: '${userApplication.id}'`},\n },\n //…\n})`\n output.print(`\\nAdd ${chalk.cyan(`appId: '${userApplication.id}'`)}`)\n output.print(`to the \\`deployment\\` section in sanity.cli.js or sanity.cli.ts`)\n output.print(`to avoid prompting for appId on next deploy.`)\n output.print(`\\n${example}`)\n }\n } catch (err) {\n spinner.fail()\n debug('Error deploying application', err)\n throw err\n }\n}\n"],"names":["deployAppAction","args","context","apiClient","workDir","chalk","output","prompt","cliConfig","flags","build","extOptions","customSourceDir","argsWithoutOptions","sourceDir","path","resolve","process","cwd","join","isAutoUpdating","shouldAutoUpdate","installedSanityVersion","getInstalledSanityVersion","appId","getAppId","client","requireUser","requireProject","withConfig","apiVersion","relativeOutput","relative","dirIsEmptyOrNonExistent","single","type","message","default","print","spinner","start","userApplication","configParams","getOrCreateUserApplicationFromConfig","appHost","undefined","getOrCreateApplication","err","error","red","debug","buildArgs","filter","Boolean","didCompile","buildSanityApp","basePath","checkDir","succeed","fail","parentDir","dirname","base","basename","tarball","tar","pack","entries","pipe","zlib","createGzip","createDeployment","applicationId","id","version","isApp","example","cyan"],"mappings":";;;;;;AAyBA,eAA8BA,gBAC5BC,MACAC,SACe;AACf,QAAM;AAAA,IAACC;AAAAA,IAAWC;AAAAA,IAASC;AAAAA,IAAOC;AAAAA,IAAQC;AAAAA,IAAQC;AAAAA,EAAwB,IAAIN,SACxEO,QAAQ;AAAA,IAACC,OAAO;AAAA,IAAM,GAAGT,KAAKU;AAAAA,EAAAA,GAC9BC,kBAAkBX,KAAKY,mBAAmB,CAAC,GAC3CC,YAAYC,cAAAA,QAAKC,QAAQC,QAAQC,OAAON,mBAAmBG,cAAAA,QAAKI,KAAKf,SAAS,MAAM,CAAC,GAErFgB,iBAAiBC,uCAAiB;AAAA,IAACZ;AAAAA,IAAOD;AAAAA,EAAAA,CAAU,GAEpDc,yBAAyB,MAAMC,QAAAA,0BAAAA,GAC/BC,QAAQC,SAAAA,SAAS;AAAA,IAACjB;AAAAA,IAAWF;AAAAA,EAAAA,CAAO,GAEpCoB,SAASvB,UAAU;AAAA,IACvBwB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AQoB,KAAAA,GACRT,QAAAA,MAAM,+BAA+BH,GAAG,GAClCA;AAAAA,EACR;AACF;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- var path = require("node:path"), zlib = require("node:zlib"), tar = require("tar-fs"), shouldAutoUpdate = require("./shouldAutoUpdate.js"), buildAction = require("./buildAction2.js"), deploySchemasAction = require("./deploySchemasAction.js"), schemaStoreOutStrings = require("./schemaStoreOutStrings.js"), helpers = require("./helpers.js");
2
+ var path = require("node:path"), zlib = require("node:zlib"), tar = require("tar-fs"), getAppId = require("./getAppId.js"), warnAboutMissingAppId = require("./warnAboutMissingAppId.js"), buildAction = require("./buildAction2.js"), deploySchemasAction = require("./deploySchemasAction.js"), schemaStoreOutStrings = require("./schemaStoreOutStrings.js"), helpers = require("./helpers.js");
3
3
  function _interopDefaultCompat(e) {
4
4
  return e && typeof e == "object" && "default" in e ? e : { default: e };
5
5
  }
@@ -15,11 +15,11 @@ async function deployStudioAction(args, context) {
15
15
  } = context, flags = {
16
16
  build: !0,
17
17
  ...args.extOptions
18
- }, customSourceDir = args.argsWithoutOptions[0], sourceDir = path__default.default.resolve(process.cwd(), customSourceDir || path__default.default.join(workDir, "dist")), isAutoUpdating = shouldAutoUpdate.shouldAutoUpdate({
18
+ }, customSourceDir = args.argsWithoutOptions[0], sourceDir = path__default.default.resolve(process.cwd(), customSourceDir || path__default.default.join(workDir, "dist")), isAutoUpdating = warnAboutMissingAppId.shouldAutoUpdate({
19
19
  flags,
20
20
  cliConfig,
21
21
  output
22
- }), installedSanityVersion = await helpers.getInstalledSanityVersion(), configStudioHost = cliConfig && "studioHost" in cliConfig && cliConfig.studioHost, client = apiClient({
22
+ }), installedSanityVersion = await helpers.getInstalledSanityVersion(), client = apiClient({
23
23
  requireUser: !0,
24
24
  requireProject: !0
25
25
  }).withConfig({
@@ -40,13 +40,24 @@ async function deployStudioAction(args, context) {
40
40
  output.print(`Building to ${relativeOutput}
41
41
  `);
42
42
  }
43
- let spinner = output.spinner("Checking project info").start(), userApplication;
43
+ let spinner = output.spinner("Checking project info").start();
44
+ const appId = getAppId.getAppId({
45
+ cliConfig,
46
+ output
47
+ }), configStudioHost = cliConfig && "studioHost" in cliConfig ? cliConfig.studioHost : void 0;
48
+ let userApplication;
44
49
  try {
45
- configStudioHost ? userApplication = await helpers.getOrCreateUserApplicationFromConfig({
50
+ appId || configStudioHost ? userApplication = await helpers.getOrCreateUserApplicationFromConfig({
46
51
  client,
47
52
  context,
48
53
  spinner,
49
- appHost: configStudioHost
54
+ ...appId ? {
55
+ appId,
56
+ appHost: void 0
57
+ } : {
58
+ appId: void 0,
59
+ appHost: configStudioHost
60
+ }
50
61
  }) : userApplication = await helpers.getOrCreateStudio({
51
62
  client,
52
63
  context,
@@ -101,9 +112,20 @@ async function deployStudioAction(args, context) {
101
112
  isAutoUpdating,
102
113
  tarball
103
114
  });
104
- spinner.succeed(), output.print(`
105
- Success! Studio deployed to ${chalk.cyan(location)}`), configStudioHost || (output.print(`
106
- Add ${chalk.cyan(`studioHost: '${userApplication.appHost}'`)}`), output.print("to defineCliConfig root properties in sanity.cli.js or sanity.cli.ts"), output.print("to avoid prompting for hostname on next deploy."));
115
+ if (spinner.succeed(), output.print(`
116
+ Success! Studio deployed to ${chalk.cyan(location)}`), !appId) {
117
+ const example = `Example:
118
+ export default defineCliConfig({
119
+ //\u2026
120
+ deployment: {
121
+ ${chalk.cyan`appId: '${userApplication.id}'`},
122
+ },
123
+ //\u2026
124
+ })`;
125
+ output.print(`
126
+ Add ${chalk.cyan(`appId: '${userApplication.id}'`)}`), output.print("to the `deployment` section in sanity.cli.js or sanity.cli.ts"), output.print("to avoid prompting for application id on next deploy."), output.print(`
127
+ ${example}`);
128
+ }
107
129
  } catch (err) {
108
130
  throw spinner.fail(), helpers.debug("Error deploying studio", err), err;
109
131
  }
@@ -1 +1 @@
1
- {"version":3,"file":"deployAction2.js","sources":["../../src/_internal/cli/actions/deploy/deployAction.ts"],"sourcesContent":["/* eslint-disable max-statements */\nimport path from 'node:path'\nimport zlib from 'node:zlib'\n\nimport {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\nimport tar from 'tar-fs'\n\nimport {shouldAutoUpdate} from '../../util/shouldAutoUpdate'\nimport buildSanityStudio, {type BuildSanityStudioCommandFlags} from '../build/buildAction'\nimport {deploySchemasAction} from '../schema/deploySchemasAction'\nimport {createManifestExtractor} from '../schema/utils/mainfestExtractor'\nimport {\n checkDir,\n createDeployment,\n debug,\n dirIsEmptyOrNonExistent,\n getInstalledSanityVersion,\n getOrCreateStudio,\n getOrCreateUserApplicationFromConfig,\n type UserApplication,\n} from './helpers'\n\nexport interface DeployStudioActionFlags extends BuildSanityStudioCommandFlags {\n 'build'?: boolean\n 'schema-required'?: boolean\n 'verbose'?: boolean\n}\n\nexport default async function deployStudioAction(\n args: CliCommandArguments<DeployStudioActionFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const {apiClient, workDir, chalk, output, prompt, cliConfig} = context\n const flags = {build: true, ...args.extOptions}\n const customSourceDir = args.argsWithoutOptions[0]\n const sourceDir = path.resolve(process.cwd(), customSourceDir || path.join(workDir, 'dist'))\n const isAutoUpdating = shouldAutoUpdate({flags, cliConfig, output})\n\n const installedSanityVersion = await getInstalledSanityVersion()\n const configStudioHost = cliConfig && 'studioHost' in cliConfig && cliConfig.studioHost\n\n const client = apiClient({\n requireUser: true,\n requireProject: true,\n }).withConfig({apiVersion: 'v2024-08-01'})\n\n if (customSourceDir === 'graphql') {\n throw new Error('Did you mean `sanity graphql deploy`?')\n }\n\n if (customSourceDir) {\n let relativeOutput = path.relative(process.cwd(), sourceDir)\n if (relativeOutput[0] !== '.') {\n relativeOutput = `./${relativeOutput}`\n }\n\n const isEmpty = await dirIsEmptyOrNonExistent(sourceDir)\n const shouldProceed =\n isEmpty ||\n (await prompt.single({\n type: 'confirm',\n message: `\"${relativeOutput}\" is not empty, do you want to proceed?`,\n default: false,\n }))\n\n if (!shouldProceed) {\n output.print('Cancelled.')\n return\n }\n\n output.print(`Building to ${relativeOutput}\\n`)\n }\n\n // Check that the project has a studio hostname\n let spinner = output.spinner('Checking project info').start()\n\n let userApplication: UserApplication\n\n try {\n // If the user has provided a studioHost in the config, use that\n if (configStudioHost) {\n userApplication = await getOrCreateUserApplicationFromConfig({\n client,\n context,\n spinner,\n appHost: configStudioHost,\n })\n } else {\n userApplication = await getOrCreateStudio({client, context, spinner})\n }\n } catch (err) {\n if (err.message) {\n output.error(chalk.red(err.message))\n return\n }\n\n debug('Error creating user application', err)\n throw err\n }\n\n // Always build the project, unless --no-build is passed\n const shouldBuild = flags.build\n if (shouldBuild) {\n const buildArgs = {\n ...args,\n extOptions: flags,\n argsWithoutOptions: [customSourceDir].filter(Boolean),\n }\n const {didCompile} = await buildSanityStudio(buildArgs, context, {basePath: '/'})\n\n if (!didCompile) {\n return\n }\n }\n\n await deploySchemasAction(\n {\n 'extract-manifest': shouldBuild,\n 'manifest-dir': `${sourceDir}/static`,\n 'schema-required': flags['schema-required'],\n 'verbose': flags.verbose,\n },\n {...context, manifestExtractor: createManifestExtractor(context)},\n )\n\n // Ensure that the directory exists, is a directory and seems to have valid content\n spinner = output.spinner('Verifying local content').start()\n try {\n await checkDir(sourceDir)\n spinner.succeed()\n } catch (err) {\n spinner.fail()\n debug('Error checking directory', err)\n throw err\n }\n\n // Now create a tarball of the given directory\n const parentDir = path.dirname(sourceDir)\n const base = path.basename(sourceDir)\n const tarball = tar.pack(parentDir, {entries: [base]}).pipe(zlib.createGzip())\n\n spinner = output.spinner('Deploying to sanity.studio').start()\n try {\n const {location} = await createDeployment({\n client,\n applicationId: userApplication.id,\n version: installedSanityVersion,\n isAutoUpdating,\n tarball,\n })\n\n spinner.succeed()\n\n // And let the user know we're done\n output.print(`\\nSuccess! Studio deployed to ${chalk.cyan(location)}`)\n\n if (!configStudioHost) {\n output.print(`\\nAdd ${chalk.cyan(`studioHost: '${userApplication.appHost}'`)}`)\n output.print(`to defineCliConfig root properties in sanity.cli.js or sanity.cli.ts`)\n output.print(`to avoid prompting for hostname on next deploy.`)\n }\n } catch (err) {\n spinner.fail()\n debug('Error deploying studio', err)\n throw err\n }\n}\n"],"names":["deployStudioAction","args","context","apiClient","workDir","chalk","output","prompt","cliConfig","flags","build","extOptions","customSourceDir","argsWithoutOptions","sourceDir","path","resolve","process","cwd","join","isAutoUpdating","shouldAutoUpdate","installedSanityVersion","getInstalledSanityVersion","configStudioHost","studioHost","client","requireUser","requireProject","withConfig","apiVersion","Error","relativeOutput","relative","dirIsEmptyOrNonExistent","single","type","message","default","print","spinner","start","userApplication","getOrCreateUserApplicationFromConfig","appHost","getOrCreateStudio","err","error","red","debug","shouldBuild","buildArgs","filter","Boolean","didCompile","buildSanityStudio","basePath","deploySchemasAction","verbose","manifestExtractor","createManifestExtractor","checkDir","succeed","fail","parentDir","dirname","base","basename","tarball","tar","pack","entries","pipe","zlib","createGzip","location","createDeployment","applicationId","id","version","cyan"],"mappings":";;;;;;AA4BA,eAA8BA,mBAC5BC,MACAC,SACe;AACf,QAAM;AAAA,IAACC;AAAAA,IAAWC;AAAAA,IAASC;AAAAA,IAAOC;AAAAA,IAAQC;AAAAA,IAAQC;AAAAA,EAAAA,IAAaN,SACzDO,QAAQ;AAAA,IAACC,OAAO;AAAA,IAAM,GAAGT,KAAKU;AAAAA,EAAAA,GAC9BC,kBAAkBX,KAAKY,mBAAmB,CAAC,GAC3CC,YAAYC,cAAAA,QAAKC,QAAQC,QAAQC,OAAON,mBAAmBG,cAAAA,QAAKI,KAAKf,SAAS,MAAM,CAAC,GACrFgB,iBAAiBC,kCAAiB;AAAA,IAACZ;AAAAA,IAAOD;AAAAA,IAAWF;AAAAA,EAAAA,CAAO,GAE5DgB,yBAAyB,MAAMC,QAAAA,0BAAAA,GAC/BC,mBAAmBhB,aAAa,gBAAgBA,aAAaA,UAAUiB,YAEvEC,SAASvB,UAAU;AAAA,IACvBwB,aAAa;AAAA,IACbC,gBAAgB;AAAA,EAAA,CACjB,EAAEC,WAAW;AA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AAO,GAAG,CAAC,EAAE,GAC9EtC,OAAOiC,MAAM,sEAAsE,GACnFjC,OAAOiC,MAAM,iDAAiD;AAAA,EAElE,SAASO,KAAK;AACZN,UAAAA,QAAQuB,KAAAA,GACRd,QAAAA,MAAM,0BAA0BH,GAAG,GAC7BA;AAAAA,EACR;AACF;;"}
1
+ {"version":3,"file":"deployAction2.js","sources":["../../src/_internal/cli/actions/deploy/deployAction.ts"],"sourcesContent":["/* eslint-disable max-statements */\nimport path from 'node:path'\nimport zlib from 'node:zlib'\n\nimport {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\nimport tar from 'tar-fs'\n\nimport {getAppId} from '../../util/getAppId'\nimport {shouldAutoUpdate} from '../../util/shouldAutoUpdate'\nimport buildSanityStudio, {type BuildSanityStudioCommandFlags} from '../build/buildAction'\nimport {deploySchemasAction} from '../schema/deploySchemasAction'\nimport {createManifestExtractor} from '../schema/utils/mainfestExtractor'\nimport {\n checkDir,\n createDeployment,\n debug,\n dirIsEmptyOrNonExistent,\n getInstalledSanityVersion,\n getOrCreateStudio,\n getOrCreateUserApplicationFromConfig,\n type UserApplication,\n} from './helpers'\n\nexport interface DeployStudioActionFlags extends BuildSanityStudioCommandFlags {\n 'build'?: boolean\n 'schema-required'?: boolean\n 'verbose'?: boolean\n}\n\nexport default async function deployStudioAction(\n args: CliCommandArguments<DeployStudioActionFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const {apiClient, workDir, chalk, output, prompt, cliConfig} = context\n const flags = {build: true, ...args.extOptions}\n const customSourceDir = args.argsWithoutOptions[0]\n const sourceDir = path.resolve(process.cwd(), customSourceDir || path.join(workDir, 'dist'))\n const isAutoUpdating = shouldAutoUpdate({flags, cliConfig, output})\n\n const installedSanityVersion = await getInstalledSanityVersion()\n\n const client = apiClient({\n requireUser: true,\n requireProject: true,\n }).withConfig({apiVersion: 'v2024-08-01'})\n\n if (customSourceDir === 'graphql') {\n throw new Error('Did you mean `sanity graphql deploy`?')\n }\n\n if (customSourceDir) {\n let relativeOutput = path.relative(process.cwd(), sourceDir)\n if (relativeOutput[0] !== '.') {\n relativeOutput = `./${relativeOutput}`\n }\n\n const isEmpty = await dirIsEmptyOrNonExistent(sourceDir)\n const shouldProceed =\n isEmpty ||\n (await prompt.single({\n type: 'confirm',\n message: `\"${relativeOutput}\" is not empty, do you want to proceed?`,\n default: false,\n }))\n\n if (!shouldProceed) {\n output.print('Cancelled.')\n return\n }\n\n output.print(`Building to ${relativeOutput}\\n`)\n }\n\n // Check that the project has a studio hostname\n let spinner = output.spinner('Checking project info').start()\n\n const appId = getAppId({cliConfig, output})\n const configStudioHost = cliConfig && 'studioHost' in cliConfig ? cliConfig.studioHost : undefined\n\n let userApplication: UserApplication\n try {\n // If the user has provided an appId in the config, use that\n if (appId || configStudioHost) {\n userApplication = await getOrCreateUserApplicationFromConfig({\n client,\n context,\n spinner,\n ...(appId ? {appId, appHost: undefined} : {appId: undefined, appHost: configStudioHost}),\n })\n } else {\n userApplication = await getOrCreateStudio({client, context, spinner})\n }\n } catch (err) {\n if (err.message) {\n output.error(chalk.red(err.message))\n return\n }\n\n debug('Error creating user application', err)\n throw err\n }\n\n // Always build the project, unless --no-build is passed\n const shouldBuild = flags.build\n if (shouldBuild) {\n const buildArgs = {\n ...args,\n extOptions: flags,\n argsWithoutOptions: [customSourceDir].filter(Boolean),\n }\n const {didCompile} = await buildSanityStudio(buildArgs, context, {basePath: '/'})\n\n if (!didCompile) {\n return\n }\n }\n\n await deploySchemasAction(\n {\n 'extract-manifest': shouldBuild,\n 'manifest-dir': `${sourceDir}/static`,\n 'schema-required': flags['schema-required'],\n 'verbose': flags.verbose,\n },\n {...context, manifestExtractor: createManifestExtractor(context)},\n )\n\n // Ensure that the directory exists, is a directory and seems to have valid content\n spinner = output.spinner('Verifying local content').start()\n try {\n await checkDir(sourceDir)\n spinner.succeed()\n } catch (err) {\n spinner.fail()\n debug('Error checking directory', err)\n throw err\n }\n\n // Now create a tarball of the given directory\n const parentDir = path.dirname(sourceDir)\n const base = path.basename(sourceDir)\n const tarball = tar.pack(parentDir, {entries: [base]}).pipe(zlib.createGzip())\n\n spinner = output.spinner('Deploying to sanity.studio').start()\n try {\n const {location} = await createDeployment({\n client,\n applicationId: userApplication.id,\n version: installedSanityVersion,\n isAutoUpdating,\n tarball,\n })\n\n spinner.succeed()\n\n // And let the user know we're done\n output.print(`\\nSuccess! Studio deployed to ${chalk.cyan(location)}`)\n\n if (!appId) {\n const example = `Example:\nexport default defineCliConfig({\n //…\n deployment: {\n ${chalk.cyan`appId: '${userApplication.id}'`},\n },\n //…\n})`\n output.print(`\\nAdd ${chalk.cyan(`appId: '${userApplication.id}'`)}`)\n output.print(`to the \\`deployment\\` section in sanity.cli.js or sanity.cli.ts`)\n output.print(`to avoid prompting for application id on next deploy.`)\n output.print(`\\n${example}`)\n }\n } catch (err) {\n spinner.fail()\n debug('Error deploying studio', err)\n throw err\n }\n}\n"],"names":["deployStudioAction","args","context","apiClient","workDir","chalk","output","prompt","cliConfig","flags","build","extOptions","customSourceDir","argsWithoutOptions","sourceDir","path","resolve","process","cwd","join","isAutoUpdating","shouldAutoUpdate","installedSanityVersion","getInstalledSanityVersion","client","requireUser","requireProject","withConfig","apiVersion","Error","relativeOutput","relative","dirIsEmptyOrNonExistent","single","type","message","default","print","spinner","start","appId","getAppId","configStudioHost","studioHost","undefined","userApplication","getOrCreateUserApplicationFromConfig","appHost","getOrCreateStudio","err","error","red","debug","shouldBuild","buildArgs","filter","Boolean","didCompile","buildSanityStudio","basePath","deploySchemasAction","verbose","manifestExtractor","createManifestExtractor","checkDir","succeed","fail","parentDir","dirname","base","basename","tarball","tar","pack","entries","pipe","zlib","createGzip","location","createDeployment","applicationId","id","version","cyan","example"],"mappings":";;;;;;AA6BA,eAA8BA,mBAC5BC,MACAC,SACe;AACf,QAAM;AAAA,IAACC;AAAAA,IAAWC;AAAAA,IAASC;AAAAA,IAAOC;AAAAA,IAAQC;AAAAA,IAAQC;AAAAA,EAAAA,IAA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Q4B,KAAAA,GACRd,QAAAA,MAAM,4BAA4BH,GAAG,GAC/BA;AAAAA,EACR;AAGA,QAAMkB,YAAYpD,cAAAA,QAAKqD,QAAQtD,SAAS,GAClCuD,OAAOtD,cAAAA,QAAKuD,SAASxD,SAAS,GAC9ByD,UAAUC,aAAAA,QAAIC,KAAKN,WAAW;AAAA,IAACO,SAAS,CAACL,IAAI;AAAA,EAAA,CAAE,EAAEM,KAAKC,sBAAKC,YAAY;AAE7EvC,YAAUhC,OAAOgC,QAAQ,4BAA4B,EAAEC,MAAAA;AACvD,MAAI;AACF,UAAM;AAAA,MAACuC;AAAAA,IAAAA,IAAY,MAAMC,QAAAA,iBAAiB;AAAA,MACxCvD;AAAAA,MACAwD,eAAenC,gBAAgBoC;AAAAA,MAC/BC,SAAS5D;AAAAA,MACTF;AAAAA,MACAmD;AAAAA,IAAAA,CACD;AAOD,QALAjC,QAAQ2B,WAGR3D,OAAO+B,MAAM;AAAA,8BAAiChC,MAAM8E,KAAKL,QAAQ,CAAC,EAAE,GAEhE,CAACtC,OAAO;AACV,YAAM4C,UAAU;AAAA;AAAA;AAAA;AAAA,MAIhB/E,MAAM8E,eAAetC,gBAAgBoC,EAAE,GAAG;AAAA;AAAA;AAAA;AAI1C3E,aAAO+B,MAAM;AAAA,MAAShC,MAAM8E,KAAK,WAAWtC,gBAAgBoC,EAAE,GAAG,CAAC,EAAE,GACpE3E,OAAO+B,MAAM,+DAAiE,GAC9E/B,OAAO+B,MAAM,uDAAuD,GACpE/B,OAAO+B,MAAM;AAAA,EAAK+C,OAAO,EAAE;AAAA,IAC7B;AAAA,EACF,SAASnC,KAAK;AACZX,UAAAA,QAAQ4B,KAAAA,GACRd,QAAAA,MAAM,0BAA0BH,GAAG,GAC7BA;AAAAA,EACR;AACF;;"}
@@ -38,12 +38,12 @@ async function startAppDevServer(args, context) {
38
38
  isApp: !0
39
39
  }), {
40
40
  port
41
- } = server.config.server, httpHost = config.httpHost || "localhost", coreAppUrl = await devAction.getCoreAppURL({
41
+ } = server.config.server, httpHost = config.httpHost || "localhost", dashboardAppUrl = await devAction.getDashboardAppURL({
42
42
  organizationId,
43
43
  httpHost,
44
44
  httpPort: port
45
45
  });
46
- output.print(`Dev server started on port ${port}`), output.print("View your app in the Sanity dashboard here:"), output.print(chalk__default.default.blue(chalk__default.default.underline(coreAppUrl)));
46
+ output.print(`Dev server started on port ${port}`), output.print("View your app in the Sanity dashboard here:"), output.print(chalk__default.default.blue(chalk__default.default.underline(dashboardAppUrl)));
47
47
  } catch (err) {
48
48
  servers.gracefulServerDeath("dev", config.httpHost, config.httpPort, err);
49
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"devAction.js","sources":["../../src/_internal/cli/actions/app/devAction.ts"],"sourcesContent":["import {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\nimport chalk from 'chalk'\nimport {hideBin} from 'yargs/helpers'\nimport yargs from 'yargs/yargs'\n\nimport {startDevServer} from '../../server/devServer'\nimport {gracefulServerDeath} from '../../util/servers'\nimport {getCoreAppURL, getDevServerConfig, type StartDevServerCommandFlags} from '../dev/devAction'\n\nfunction parseCliFlags(args: {argv?: string[]}) {\n // Using slice(1) to remove the first argument, which is the command `dev` path to the CLI\n return yargs(hideBin(args.argv || process.argv).slice(1))\n .options('host', {type: 'string'})\n .options('port', {type: 'number'})\n .options('load-in-dashboard', {type: 'boolean', default: true}).argv\n}\n\nexport default async function startAppDevServer(\n args: CliCommandArguments<StartDevServerCommandFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const flags = await parseCliFlags(args)\n const {output, workDir, cliConfig} = context\n\n if (!flags.loadInDashboard) {\n output.warn(`Apps cannot run without the Sanity dashboard`)\n output.warn(`Starting dev server with the --load-in-dashboard flag set to true`)\n }\n\n let organizationId: string | undefined\n if (cliConfig && 'app' in cliConfig && cliConfig.app?.organizationId) {\n organizationId = cliConfig.app.organizationId\n }\n\n if (!organizationId) {\n output.error(`Apps require an organization ID (orgId) specified in your sanity.cli.ts file`)\n process.exit(1)\n }\n\n // Try to load CLI configuration from sanity.cli.(js|ts)\n const config = getDevServerConfig({\n flags,\n workDir,\n cliConfig,\n output,\n })\n\n try {\n output.print('Starting dev server')\n\n const {server} = await startDevServer({...config, isApp: true})\n\n const {port} = server.config.server\n const httpHost = config.httpHost || 'localhost'\n\n const coreAppUrl = await getCoreAppURL({\n organizationId,\n httpHost,\n httpPort: port,\n })\n\n output.print(`Dev server started on port ${port}`)\n output.print(`View your app in the Sanity dashboard here:`)\n output.print(chalk.blue(chalk.underline(coreAppUrl)))\n } catch (err) {\n gracefulServerDeath('dev', config.httpHost, config.httpPort, err)\n }\n}\n"],"names":["parseCliFlags","args","yargs","hideBin","argv","process","slice","options","type","default","startAppDevServer","context","flags","output","workDir","cliConfig","loadInDashboard","warn","organizationId","app","error","exit","config","getDevServerConfig","print","server","startDevServer","isApp","port","httpHost","coreAppUrl","getCoreAppURL","httpPort","chalk","blue","underline","err","gracefulServerDeath"],"mappings":";;;;;;AASA,SAASA,cAAcC,MAAyB;AAE9C,SAAOC,uBAAMC,QAAAA,QAAQF,KAAKG,QAAQC,QAAQD,IAAI,EAAEE,MAAM,CAAC,CAAC,EACrDC,QAAQ,QAAQ;AAAA,IAACC,MAAM;AAAA,EAAA,CAAS,EAChCD,QAAQ,QAAQ;AAAA,IAACC,MAAM;AAAA,EAAA,CAAS,EAChCD,QAAQ,qBAAqB;AAAA,IAACC,MAAM;AAAA,IAAWC,SAAS;AAAA,EAAA,CAAK,EAAEL;AACpE;AAEA,eAA8BM,kBAC5BT,MACAU,SACe;AACf,QAAMC,QAAQ,MAAMZ,cAAcC,IAAI,GAChC;AAAA,IAACY;AAAAA,IAAQC;AAAAA,IAASC;AAAAA,EAAAA,IAAaJ;AAEhCC,QAAMI,oBACTH,OAAOI,KAAK,8CAA8C,GAC1DJ,OAAOI,KAAK,mEAAmE;AAGjF,MAAIC;AACAH,eAAa,SAASA,aAAaA,UAAUI,KAAKD,mBACpDA,iBAAiBH,UAAUI,IAAID,iBAG5BA,mBACHL,OAAOO,MAAM,8EAA8E,GAC3Ff,QAAQgB,KAAK,CAAC;AAIhB,QAAMC,SAASC,UAAAA,mBAAmB;AAAA,IAChCX;AAAAA,IACAE;AAAAA,IACAC;AAAAA,IACAF;AAAAA,EAAAA,CACD;AAED,MAAI;AACFA,WAAOW,MAAM,qBAAqB;AAElC,UAAM;AAAA,MAACC;AAAAA,IAAAA,IAAU,MAAMC,UAAAA,eAAe;AAAA,MAAC,GAAGJ;AAAAA,MAAQK,OAAO;AAAA,IAAA,CAAK,GAExD;AAAA,MAACC;AAAAA,IAAAA,IAAQH,OAAOH,OAAOG,QACvBI,WAAWP,OAAOO,YAAY,aAE9BC,aAAa,MAAMC,wBAAc;AAAA,MACrCb;AAAAA,MACAW;AAAAA,MACAG,UAAUJ;AAAAA,IAAAA,CACX;AAEDf,WAAOW,MAAM,8BAA8BI,IAAI,EAAE,GACjDf,OAAOW,MAAM,6CAA6C,GAC1DX,OAAOW,MAAMS,uBAAMC,KAAKD,eAAAA,QAAME,UAAUL,UAAU,CAAC,CAAC;AAAA,EACtD,SAASM,KAAK;AACZC,YAAAA,oBAAoB,OAAOf,OAAOO,UAAUP,OAAOU,UAAUI,GAAG;AAAA,EAClE;AACF;;"}
1
+ {"version":3,"file":"devAction.js","sources":["../../src/_internal/cli/actions/app/devAction.ts"],"sourcesContent":["import {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\nimport chalk from 'chalk'\nimport {hideBin} from 'yargs/helpers'\nimport yargs from 'yargs/yargs'\n\nimport {startDevServer} from '../../server/devServer'\nimport {gracefulServerDeath} from '../../util/servers'\nimport {\n getDashboardAppURL,\n getDevServerConfig,\n type StartDevServerCommandFlags,\n} from '../dev/devAction'\n\nfunction parseCliFlags(args: {argv?: string[]}) {\n // Using slice(1) to remove the first argument, which is the command `dev` path to the CLI\n return yargs(hideBin(args.argv || process.argv).slice(1))\n .options('host', {type: 'string'})\n .options('port', {type: 'number'})\n .options('load-in-dashboard', {type: 'boolean', default: true}).argv\n}\n\nexport default async function startAppDevServer(\n args: CliCommandArguments<StartDevServerCommandFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const flags = await parseCliFlags(args)\n const {output, workDir, cliConfig} = context\n\n if (!flags.loadInDashboard) {\n output.warn(`Apps cannot run without the Sanity dashboard`)\n output.warn(`Starting dev server with the --load-in-dashboard flag set to true`)\n }\n\n let organizationId: string | undefined\n if (cliConfig && 'app' in cliConfig && cliConfig.app?.organizationId) {\n organizationId = cliConfig.app.organizationId\n }\n\n if (!organizationId) {\n output.error(`Apps require an organization ID (orgId) specified in your sanity.cli.ts file`)\n process.exit(1)\n }\n\n // Try to load CLI configuration from sanity.cli.(js|ts)\n const config = getDevServerConfig({\n flags,\n workDir,\n cliConfig,\n output,\n })\n\n try {\n output.print('Starting dev server')\n\n const {server} = await startDevServer({...config, isApp: true})\n\n const {port} = server.config.server\n const httpHost = config.httpHost || 'localhost'\n\n const dashboardAppUrl = await getDashboardAppURL({\n organizationId,\n httpHost,\n httpPort: port,\n })\n\n output.print(`Dev server started on port ${port}`)\n output.print(`View your app in the Sanity dashboard here:`)\n output.print(chalk.blue(chalk.underline(dashboardAppUrl)))\n } catch (err) {\n gracefulServerDeath('dev', config.httpHost, config.httpPort, err)\n }\n}\n"],"names":["parseCliFlags","args","yargs","hideBin","argv","process","slice","options","type","default","startAppDevServer","context","flags","output","workDir","cliConfig","loadInDashboard","warn","organizationId","app","error","exit","config","getDevServerConfig","print","server","startDevServer","isApp","port","httpHost","dashboardAppUrl","getDashboardAppURL","httpPort","chalk","blue","underline","err","gracefulServerDeath"],"mappings":";;;;;;AAaA,SAASA,cAAcC,MAAyB;AAE9C,SAAOC,uBAAMC,QAAAA,QAAQF,KAAKG,QAAQC,QAAQD,IAAI,EAAEE,MAAM,CAAC,CAAC,EACrDC,QAAQ,QAAQ;AAAA,IAACC,MAAM;AAAA,EAAA,CAAS,EAChCD,QAAQ,QAAQ;AAAA,IAACC,MAAM;AAAA,EA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