@sanity/cli 6.5.0 → 6.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +190 -98
  2. package/dist/actions/build/buildApp.js +35 -14
  3. package/dist/actions/build/buildApp.js.map +1 -1
  4. package/dist/actions/build/buildStudio.js +54 -26
  5. package/dist/actions/build/buildStudio.js.map +1 -1
  6. package/dist/actions/build/buildVendorDependencies.js +3 -2
  7. package/dist/actions/build/buildVendorDependencies.js.map +1 -1
  8. package/dist/actions/build/checkRequiredDependencies.js +2 -5
  9. package/dist/actions/build/checkRequiredDependencies.js.map +1 -1
  10. package/dist/actions/build/checkStudioDependencyVersions.js +1 -2
  11. package/dist/actions/build/checkStudioDependencyVersions.js.map +1 -1
  12. package/dist/actions/build/getViteConfig.js +2 -1
  13. package/dist/actions/build/getViteConfig.js.map +1 -1
  14. package/dist/actions/codemods/reactIconsV3.js +1 -1
  15. package/dist/actions/codemods/reactIconsV3.js.map +1 -1
  16. package/dist/actions/deploy/deployApp.js +1 -1
  17. package/dist/actions/deploy/deployApp.js.map +1 -1
  18. package/dist/actions/deploy/deployStudio.js +1 -2
  19. package/dist/actions/deploy/deployStudio.js.map +1 -1
  20. package/dist/actions/dev/startStudioDevServer.js +1 -2
  21. package/dist/actions/dev/startStudioDevServer.js.map +1 -1
  22. package/dist/actions/manifest/extractAppManifest.js +3 -2
  23. package/dist/actions/manifest/extractAppManifest.js.map +1 -1
  24. package/dist/actions/manifest/types.js +9 -0
  25. package/dist/actions/manifest/types.js.map +1 -1
  26. package/dist/actions/manifest/writeManifestFile.js +1 -2
  27. package/dist/actions/manifest/writeManifestFile.js.map +1 -1
  28. package/dist/actions/schema/uploadSchemaToLexicon.js +1 -2
  29. package/dist/actions/schema/uploadSchemaToLexicon.js.map +1 -1
  30. package/dist/actions/versions/buildPackageArray.js +1 -1
  31. package/dist/actions/versions/buildPackageArray.js.map +1 -1
  32. package/dist/constants.js +8 -0
  33. package/dist/constants.js.map +1 -0
  34. package/dist/server/previewServer.js +1 -1
  35. package/dist/server/previewServer.js.map +1 -1
  36. package/dist/services/userApplications.js.map +1 -1
  37. package/dist/util/compareDependencyVersions.js +1 -2
  38. package/dist/util/compareDependencyVersions.js.map +1 -1
  39. package/oclif.manifest.json +1 -1
  40. package/package.json +9 -9
  41. package/dist/util/getLocalPackageVersion.js +0 -55
  42. package/dist/util/getLocalPackageVersion.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/build/getViteConfig.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {\n type CliConfig,\n findProjectRoot,\n getCliTelemetry,\n type UserViteConfig,\n} from '@sanity/cli-core'\nimport viteReact from '@vitejs/plugin-react'\nimport {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport debug from 'debug'\nimport {readPackageUp} from 'read-package-up'\nimport {type ConfigEnv, type InlineConfig, mergeConfig, type Rollup} from 'vite'\n\nimport {sanityBuildEntries} from '../../server/vite/plugin-sanity-build-entries.js'\nimport {sanityFaviconsPlugin} from '../../server/vite/plugin-sanity-favicons.js'\nimport {sanityRuntimeRewritePlugin} from '../../server/vite/plugin-sanity-runtime-rewrite.js'\nimport {sanitySchemaExtractionPlugin} from '../../server/vite/plugin-schema-extraction.js'\nimport {sanityTypegenPlugin} from '../../server/vite/plugin-typegen.js'\nimport {createExternalFromImportMap} from './createExternalFromImportMap.js'\nimport {\n getAppEnvironmentVariables,\n getStudioEnvironmentVariables,\n} from './getStudioEnvironmentVariables.js'\nimport {normalizeBasePath} from './normalizeBasePath.js'\n\ninterface ViteOptions {\n /**\n * Root path of the studio/sanity app\n */\n cwd: string\n\n /**\n * Mode to run vite in - eg development or production\n */\n mode: 'development' | 'production'\n\n reactCompiler: ReactCompilerConfig | undefined\n\n /**\n * CSS URLs for auto-updated packages (loaded via module server)\n */\n autoUpdatesCssUrls?: string[]\n\n /**\n * Base path (eg under where to serve the app - `/studio` or similar)\n * Will be normalized to ensure it starts and ends with a `/`\n */\n basePath?: string\n\n importMap?: {imports?: Record<string, string>}\n\n isApp?: boolean\n\n /**\n * Whether or not to minify the output (only used in `mode: 'production'`)\n */\n minify?: boolean\n\n /**\n * Output directory (eg where to place the built files, if any)\n */\n outputDir?: string\n /**\n * Schema extraction configuration\n */\n schemaExtraction?: CliConfig['schemaExtraction']\n /**\n * HTTP development server configuration\n */\n server?: {host?: string; port?: number}\n /**\n * Whether or not to enable source maps\n */\n sourceMap?: boolean\n /**\n * Typegen configuration\n */\n typegen?: CliConfig['typegen']\n}\n\n/**\n * Get a configuration object for Vite based on the passed options\n *\n * @internal Only meant for consumption inside of Sanity modules, do not depend on this externally\n */\nexport async function getViteConfig(options: ViteOptions): Promise<InlineConfig> {\n const {\n autoUpdatesCssUrls,\n basePath: rawBasePath = '/',\n cwd,\n importMap,\n isApp,\n minify,\n mode,\n outputDir,\n reactCompiler,\n schemaExtraction,\n server,\n // default to `true` when `mode=development`\n sourceMap = options.mode === 'development',\n typegen,\n } = options\n\n const basePath = normalizeBasePath(rawBasePath)\n\n const sanityCliPkgPath = (await readPackageUp({cwd: import.meta.dirname}))?.path\n if (!sanityCliPkgPath) {\n throw new Error('Unable to resolve `@sanity/cli` module root')\n }\n\n const configPath = (await findProjectRoot(cwd)).path\n\n const customFaviconsPath = path.join(cwd, 'static')\n const defaultFaviconsPath = path.join(path.dirname(sanityCliPkgPath), 'static', 'favicons')\n const staticPath = `${basePath}static`\n\n const envVars = isApp\n ? getAppEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n : getStudioEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n\n const viteConfig: InlineConfig = {\n base: basePath,\n build: {\n outDir: outputDir || path.resolve(cwd, 'dist'),\n sourcemap: sourceMap,\n },\n // Define a custom cache directory so that sanity's vite cache\n // does not conflict with any potential local vite projects\n cacheDir: 'node_modules/.sanity/vite',\n configFile: false,\n define: {\n __SANITY_BUILD_TIMESTAMP__: JSON.stringify(Date.now()),\n __SANITY_STAGING__: process.env.SANITY_INTERNAL_ENV === 'staging',\n 'process.env.MODE': JSON.stringify(mode),\n 'process.env.PKG_BUILD_VERSION': JSON.stringify(process.env.PKG_BUILD_VERSION),\n /**\n * Yes, double negatives are confusing.\n * The default value of `SC_DISABLE_SPEEDY` is `process.env.NODE_ENV === 'production'`: https://github.com/styled-components/styled-components/blob/99c02f52d69e8e509c0bf012cadee7f8e819a6dd/packages/styled-components/src/constants.ts#L34\n * Which means that in production, use the much faster way of inserting CSS rules, based on the CSSStyleSheet API (https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule)\n * while in dev mode, use the slower way of inserting CSS rules, which appends text nodes to the `<style>` tag: https://github.com/styled-components/styled-components/blob/99c02f52d69e8e509c0bf012cadee7f8e819a6dd/packages/styled-components/src/sheet/Tag.ts#L74-L76\n * There are historical reasons for this, primarily that browsers initially did not support editing CSS rules in the DevTools inspector if `CSSStyleSheet.insetRule` were used.\n * However, that's no longer the case (since Chrome 81 back in April 2020: https://developer.chrome.com/docs/css-ui/css-in-js), the latest version of FireFox also supports it,\n * and there is no longer any reason to use the much slower method in dev mode.\n */\n 'process.env.SC_DISABLE_SPEEDY': JSON.stringify('false'),\n ...envVars,\n },\n envPrefix: isApp ? 'SANITY_APP_' : 'SANITY_STUDIO_',\n logLevel: mode === 'production' ? 'silent' : 'info',\n mode,\n plugins: [\n viteReact(\n reactCompiler\n ? {\n babel: {\n generatorOpts: {compact: true},\n plugins: [['babel-plugin-react-compiler', reactCompiler]],\n },\n }\n : {},\n ),\n sanityFaviconsPlugin({customFaviconsPath, defaultFaviconsPath, staticUrlPath: staticPath}),\n sanityRuntimeRewritePlugin(),\n sanityBuildEntries({autoUpdatesCssUrls, basePath, cwd, importMap, isApp}),\n // Add schema extraction when enabled\n ...(schemaExtraction?.enabled\n ? [\n sanitySchemaExtractionPlugin({\n additionalPatterns: schemaExtraction.watchPatterns,\n configPath,\n enforceRequiredFields: schemaExtraction.enforceRequiredFields,\n outputPath: schemaExtraction.path,\n telemetryLogger: getCliTelemetry(),\n workDir: cwd,\n workspaceName: schemaExtraction.workspace,\n }),\n ]\n : []),\n // Add typegen when enabled\n ...(typegen?.enabled\n ? [\n sanityTypegenPlugin({\n config: typegen,\n telemetryLogger: getCliTelemetry(),\n workDir: cwd,\n }),\n ]\n : []),\n ],\n resolve: {\n dedupe: ['react', 'react-dom', 'sanity', 'styled-components'],\n },\n root: cwd,\n server: {\n host: server?.host,\n port: server?.port || 3333,\n // Only enable strict port for studio,\n // since apps can run on any port\n strictPort: isApp ? false : true,\n\n /**\n * Significantly speed up startup time,\n * and most importantly eliminates the `new dependencies optimized: foobar. optimized dependencies changed. reloading`\n * types of initial reload loops that otherwise happen as vite discovers deps that need to be optimized.\n * This option starts the traversal up front, and warms up the dep tree required to render the userland sanity.config.ts file,\n * and thus avoids frustrating reload loops.\n */\n warmup: {\n clientFiles: ['./.sanity/runtime/app.js'],\n },\n },\n }\n\n if (mode === 'production') {\n viteConfig.build = {\n ...viteConfig.build,\n\n assetsDir: 'static',\n emptyOutDir: false, // Rely on CLI to do this\n minify: minify ? 'esbuild' : false,\n\n rollupOptions: {\n external: createExternalFromImportMap(importMap),\n input: {\n sanity: path.join(cwd, '.sanity', 'runtime', 'app.js'),\n },\n onwarn: onRollupWarn,\n },\n }\n }\n\n return viteConfig\n}\n\nfunction onRollupWarn(warning: Rollup.RollupLog, warn: Rollup.LoggingFunction) {\n if (suppressUnusedImport(warning)) {\n return\n }\n\n warn(warning)\n}\n\nfunction suppressUnusedImport(warning: Rollup.RollupLog & {ids?: string[]}): boolean {\n if (warning.code !== 'UNUSED_EXTERNAL_IMPORT') return false\n\n // Suppress:\n // ```\n // \"useDebugValue\" is imported from external module \"react\"…\n // ```\n if (warning.names?.includes('useDebugValue')) {\n warning.names = warning.names.filter((n) => n !== 'useDebugValue')\n if (warning.names.length === 0) return true\n }\n\n // If some library does something unexpected, we suppress since it isn't actionable\n if (warning.ids?.every((id) => id.includes('/node_modules/') || id.includes('\\\\node_modules\\\\')))\n return true\n\n return false\n}\n\n/**\n * Ensure Sanity entry chunk is always loaded\n *\n * @param config - User-modified configuration\n * @returns Merged configuration\n * @internal\n */\nexport async function finalizeViteConfig(config: InlineConfig): Promise<InlineConfig> {\n if (typeof config.build?.rollupOptions?.input !== 'object') {\n throw new TypeError(\n 'Vite config must contain `build.rollupOptions.input`, and it must be an object',\n )\n }\n\n if (!config.root) {\n throw new Error(\n 'Vite config must contain `root` property, and must point to the Sanity root directory',\n )\n }\n\n return mergeConfig(config, {\n build: {\n rollupOptions: {\n input: {\n sanity: path.join(config.root, '.sanity', 'runtime', 'app.js'),\n },\n },\n },\n })\n}\n\n/**\n * Merge user-provided Vite configuration object or function\n *\n * @param defaultConfig - Default configuration object\n * @param userConfig - User-provided configuration object or function\n * @returns Merged configuration\n * @internal\n */\nexport async function extendViteConfigWithUserConfig(\n env: ConfigEnv,\n defaultConfig: InlineConfig,\n userConfig: UserViteConfig,\n): Promise<InlineConfig> {\n let config = defaultConfig\n\n if (typeof userConfig === 'function') {\n debug('Extending vite config using user-specified function')\n config = await userConfig(config, env)\n } else if (typeof userConfig === 'object') {\n debug('Merging vite config using user-specified object')\n config = mergeConfig(config, userConfig)\n }\n\n return config\n}\n"],"names":["path","findProjectRoot","getCliTelemetry","viteReact","debug","readPackageUp","mergeConfig","sanityBuildEntries","sanityFaviconsPlugin","sanityRuntimeRewritePlugin","sanitySchemaExtractionPlugin","sanityTypegenPlugin","createExternalFromImportMap","getAppEnvironmentVariables","getStudioEnvironmentVariables","normalizeBasePath","getViteConfig","options","autoUpdatesCssUrls","basePath","rawBasePath","cwd","importMap","isApp","minify","mode","outputDir","reactCompiler","schemaExtraction","server","sourceMap","typegen","sanityCliPkgPath","dirname","Error","configPath","customFaviconsPath","join","defaultFaviconsPath","staticPath","envVars","jsonEncode","prefix","viteConfig","base","build","outDir","resolve","sourcemap","cacheDir","configFile","define","__SANITY_BUILD_TIMESTAMP__","JSON","stringify","Date","now","__SANITY_STAGING__","process","env","SANITY_INTERNAL_ENV","PKG_BUILD_VERSION","envPrefix","logLevel","plugins","babel","generatorOpts","compact","staticUrlPath","enabled","additionalPatterns","watchPatterns","enforceRequiredFields","outputPath","telemetryLogger","workDir","workspaceName","workspace","config","dedupe","root","host","port","strictPort","warmup","clientFiles","assetsDir","emptyOutDir","rollupOptions","external","input","sanity","onwarn","onRollupWarn","warning","warn","suppressUnusedImport","code","names","includes","filter","n","length","ids","every","id","finalizeViteConfig","TypeError","extendViteConfigWithUserConfig","defaultConfig","userConfig"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B,SAEEC,eAAe,EACfC,eAAe,QAEV,mBAAkB;AACzB,OAAOC,eAAe,uBAAsB;AAE5C,OAAOC,WAAW,QAAO;AACzB,SAAQC,aAAa,QAAO,kBAAiB;AAC7C,SAA2CC,WAAW,QAAoB,OAAM;AAEhF,SAAQC,kBAAkB,QAAO,mDAAkD;AACnF,SAAQC,oBAAoB,QAAO,8CAA6C;AAChF,SAAQC,0BAA0B,QAAO,qDAAoD;AAC7F,SAAQC,4BAA4B,QAAO,gDAA+C;AAC1F,SAAQC,mBAAmB,QAAO,sCAAqC;AACvE,SAAQC,2BAA2B,QAAO,mCAAkC;AAC5E,SACEC,0BAA0B,EAC1BC,6BAA6B,QACxB,qCAAoC;AAC3C,SAAQC,iBAAiB,QAAO,yBAAwB;AAyDxD;;;;CAIC,GACD,OAAO,eAAeC,cAAcC,OAAoB;IACtD,MAAM,EACJC,kBAAkB,EAClBC,UAAUC,cAAc,GAAG,EAC3BC,GAAG,EACHC,SAAS,EACTC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,SAAS,EACTC,aAAa,EACbC,gBAAgB,EAChBC,MAAM,EACN,4CAA4C;IAC5CC,YAAYb,QAAQQ,IAAI,KAAK,aAAa,EAC1CM,OAAO,EACR,GAAGd;IAEJ,MAAME,WAAWJ,kBAAkBK;IAEnC,MAAMY,mB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E,qBAAqBF,OAA4C;IACxE,IAAIA,QAAQG,IAAI,KAAK,0BAA0B,OAAO;IAEtD,YAAY;IACZ,MAAM;IACN,4DAA4D;IAC5D,MAAM;IACN,IAAIH,QAAQI,KAAK,EAAEC,SAAS,kBAAkB;QAC5CL,QAAQI,KAAK,GAAGJ,QAAQI,KAAK,CAACE,MAAM,CAAC,CAACC,IAAMA,MAAM;QAClD,IAAIP,QAAQI,KAAK,CAACI,MAAM,KAAK,GAAG,OAAO;IACzC;IAEA,mFAAmF;IACnF,IAAIR,QAAQS,GAAG,EAAEC,MAAM,CAACC,KAAOA,GAAGN,QAAQ,CAAC,qBAAqBM,GAAGN,QAAQ,CAAC,sBAC1E,OAAO;IAET,OAAO;AACT;AAEA;;;;;;CAMC,GACD,OAAO,eAAeO,mBAAmB5B,MAAoB;IAC3D,IAAI,OAAOA,OAAOjC,KAAK,EAAE2C,eAAeE,UAAU,UAAU;QAC1D,MAAM,IAAIiB,UACR;IAEJ;IAEA,IAAI,CAAC7B,OAAOE,IAAI,EAAE;QAChB,MAAM,IAAI9C,MACR;IAEJ;IAEA,OAAO5B,YAAYwE,QAAQ;QACzBjC,OAAO;YACL2C,eAAe;gBACbE,OAAO;oBACLC,QAAQ3F,KAAKqC,IAAI,CAACyC,OAAOE,IAAI,EAAE,WAAW,WAAW;gBACvD;YACF;QACF;IACF;AACF;AAEA;;;;;;;CAOC,GACD,OAAO,eAAe4B,+BACpBjD,GAAc,EACdkD,aAA2B,EAC3BC,UAA0B;IAE1B,IAAIhC,SAAS+B;IAEb,IAAI,OAAOC,eAAe,YAAY;QACpC1G,MAAM;QACN0E,SAAS,MAAMgC,WAAWhC,QAAQnB;IACpC,OAAO,IAAI,OAAOmD,eAAe,UAAU;QACzC1G,MAAM;QACN0E,SAASxE,YAAYwE,QAAQgC;IAC/B;IAEA,OAAOhC;AACT"}
1
+ {"version":3,"sources":["../../../src/actions/build/getViteConfig.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {\n type CliConfig,\n findProjectRoot,\n getCliTelemetry,\n type UserViteConfig,\n} from '@sanity/cli-core'\nimport viteReact from '@vitejs/plugin-react'\nimport {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport debug from 'debug'\nimport {readPackageUp} from 'read-package-up'\nimport {type ConfigEnv, type InlineConfig, mergeConfig, type Rollup} from 'vite'\n\nimport {SANITY_CACHE_DIR} from '../../constants.js'\nimport {sanityBuildEntries} from '../../server/vite/plugin-sanity-build-entries.js'\nimport {sanityFaviconsPlugin} from '../../server/vite/plugin-sanity-favicons.js'\nimport {sanityRuntimeRewritePlugin} from '../../server/vite/plugin-sanity-runtime-rewrite.js'\nimport {sanitySchemaExtractionPlugin} from '../../server/vite/plugin-schema-extraction.js'\nimport {sanityTypegenPlugin} from '../../server/vite/plugin-typegen.js'\nimport {createExternalFromImportMap} from './createExternalFromImportMap.js'\nimport {\n getAppEnvironmentVariables,\n getStudioEnvironmentVariables,\n} from './getStudioEnvironmentVariables.js'\nimport {normalizeBasePath} from './normalizeBasePath.js'\n\ninterface ViteOptions {\n /**\n * Root path of the studio/sanity app\n */\n cwd: string\n\n /**\n * Mode to run vite in - eg development or production\n */\n mode: 'development' | 'production'\n\n reactCompiler: ReactCompilerConfig | undefined\n\n /**\n * CSS URLs for auto-updated packages (loaded via module server)\n */\n autoUpdatesCssUrls?: string[]\n\n /**\n * Base path (eg under where to serve the app - `/studio` or similar)\n * Will be normalized to ensure it starts and ends with a `/`\n */\n basePath?: string\n\n importMap?: {imports?: Record<string, string>}\n\n isApp?: boolean\n\n /**\n * Whether or not to minify the output (only used in `mode: 'production'`)\n */\n minify?: boolean\n\n /**\n * Output directory (eg where to place the built files, if any)\n */\n outputDir?: string\n /**\n * Schema extraction configuration\n */\n schemaExtraction?: CliConfig['schemaExtraction']\n /**\n * HTTP development server configuration\n */\n server?: {host?: string; port?: number}\n /**\n * Whether or not to enable source maps\n */\n sourceMap?: boolean\n /**\n * Typegen configuration\n */\n typegen?: CliConfig['typegen']\n}\n\n/**\n * Get a configuration object for Vite based on the passed options\n *\n * @internal Only meant for consumption inside of Sanity modules, do not depend on this externally\n */\nexport async function getViteConfig(options: ViteOptions): Promise<InlineConfig> {\n const {\n autoUpdatesCssUrls,\n basePath: rawBasePath = '/',\n cwd,\n importMap,\n isApp,\n minify,\n mode,\n outputDir,\n reactCompiler,\n schemaExtraction,\n server,\n // default to `true` when `mode=development`\n sourceMap = options.mode === 'development',\n typegen,\n } = options\n\n const basePath = normalizeBasePath(rawBasePath)\n\n const sanityCliPkgPath = (await readPackageUp({cwd: import.meta.dirname}))?.path\n if (!sanityCliPkgPath) {\n throw new Error('Unable to resolve `@sanity/cli` module root')\n }\n\n const configPath = (await findProjectRoot(cwd)).path\n\n const customFaviconsPath = path.join(cwd, 'static')\n const defaultFaviconsPath = path.join(path.dirname(sanityCliPkgPath), 'static', 'favicons')\n const staticPath = `${basePath}static`\n\n const envVars = isApp\n ? getAppEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n : getStudioEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n\n const viteConfig: InlineConfig = {\n base: basePath,\n build: {\n outDir: outputDir || path.resolve(cwd, 'dist'),\n sourcemap: sourceMap,\n },\n // Define a custom cache directory so that sanity's vite cache\n // does not conflict with any potential local vite projects\n cacheDir: `${SANITY_CACHE_DIR}/vite`,\n configFile: false,\n define: {\n __SANITY_BUILD_TIMESTAMP__: JSON.stringify(Date.now()),\n __SANITY_STAGING__: process.env.SANITY_INTERNAL_ENV === 'staging',\n 'process.env.MODE': JSON.stringify(mode),\n 'process.env.PKG_BUILD_VERSION': JSON.stringify(process.env.PKG_BUILD_VERSION),\n /**\n * Yes, double negatives are confusing.\n * The default value of `SC_DISABLE_SPEEDY` is `process.env.NODE_ENV === 'production'`: https://github.com/styled-components/styled-components/blob/99c02f52d69e8e509c0bf012cadee7f8e819a6dd/packages/styled-components/src/constants.ts#L34\n * Which means that in production, use the much faster way of inserting CSS rules, based on the CSSStyleSheet API (https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule)\n * while in dev mode, use the slower way of inserting CSS rules, which appends text nodes to the `<style>` tag: https://github.com/styled-components/styled-components/blob/99c02f52d69e8e509c0bf012cadee7f8e819a6dd/packages/styled-components/src/sheet/Tag.ts#L74-L76\n * There are historical reasons for this, primarily that browsers initially did not support editing CSS rules in the DevTools inspector if `CSSStyleSheet.insetRule` were used.\n * However, that's no longer the case (since Chrome 81 back in April 2020: https://developer.chrome.com/docs/css-ui/css-in-js), the latest version of FireFox also supports it,\n * and there is no longer any reason to use the much slower method in dev mode.\n */\n 'process.env.SC_DISABLE_SPEEDY': JSON.stringify('false'),\n ...envVars,\n },\n envPrefix: isApp ? 'SANITY_APP_' : 'SANITY_STUDIO_',\n logLevel: mode === 'production' ? 'silent' : 'info',\n mode,\n plugins: [\n viteReact(\n reactCompiler\n ? {\n babel: {\n generatorOpts: {compact: true},\n plugins: [['babel-plugin-react-compiler', reactCompiler]],\n },\n }\n : {},\n ),\n sanityFaviconsPlugin({customFaviconsPath, defaultFaviconsPath, staticUrlPath: staticPath}),\n sanityRuntimeRewritePlugin(),\n sanityBuildEntries({autoUpdatesCssUrls, basePath, cwd, importMap, isApp}),\n // Add schema extraction when enabled\n ...(schemaExtraction?.enabled\n ? [\n sanitySchemaExtractionPlugin({\n additionalPatterns: schemaExtraction.watchPatterns,\n configPath,\n enforceRequiredFields: schemaExtraction.enforceRequiredFields,\n outputPath: schemaExtraction.path,\n telemetryLogger: getCliTelemetry(),\n workDir: cwd,\n workspaceName: schemaExtraction.workspace,\n }),\n ]\n : []),\n // Add typegen when enabled\n ...(typegen?.enabled\n ? [\n sanityTypegenPlugin({\n config: typegen,\n telemetryLogger: getCliTelemetry(),\n workDir: cwd,\n }),\n ]\n : []),\n ],\n resolve: {\n dedupe: ['react', 'react-dom', 'sanity', 'styled-components'],\n },\n root: cwd,\n server: {\n host: server?.host,\n port: server?.port || 3333,\n // Only enable strict port for studio,\n // since apps can run on any port\n strictPort: isApp ? false : true,\n\n /**\n * Significantly speed up startup time,\n * and most importantly eliminates the `new dependencies optimized: foobar. optimized dependencies changed. reloading`\n * types of initial reload loops that otherwise happen as vite discovers deps that need to be optimized.\n * This option starts the traversal up front, and warms up the dep tree required to render the userland sanity.config.ts file,\n * and thus avoids frustrating reload loops.\n */\n warmup: {\n clientFiles: ['./.sanity/runtime/app.js'],\n },\n },\n }\n\n if (mode === 'production') {\n viteConfig.build = {\n ...viteConfig.build,\n\n assetsDir: 'static',\n emptyOutDir: false, // Rely on CLI to do this\n minify: minify ? 'esbuild' : false,\n\n rollupOptions: {\n external: createExternalFromImportMap(importMap),\n input: {\n sanity: path.join(cwd, '.sanity', 'runtime', 'app.js'),\n },\n onwarn: onRollupWarn,\n },\n }\n }\n\n return viteConfig\n}\n\nfunction onRollupWarn(warning: Rollup.RollupLog, warn: Rollup.LoggingFunction) {\n if (suppressUnusedImport(warning)) {\n return\n }\n\n warn(warning)\n}\n\nfunction suppressUnusedImport(warning: Rollup.RollupLog & {ids?: string[]}): boolean {\n if (warning.code !== 'UNUSED_EXTERNAL_IMPORT') return false\n\n // Suppress:\n // ```\n // \"useDebugValue\" is imported from external module \"react\"…\n // ```\n if (warning.names?.includes('useDebugValue')) {\n warning.names = warning.names.filter((n) => n !== 'useDebugValue')\n if (warning.names.length === 0) return true\n }\n\n // If some library does something unexpected, we suppress since it isn't actionable\n if (warning.ids?.every((id) => id.includes('/node_modules/') || id.includes('\\\\node_modules\\\\')))\n return true\n\n return false\n}\n\n/**\n * Ensure Sanity entry chunk is always loaded\n *\n * @param config - User-modified configuration\n * @returns Merged configuration\n * @internal\n */\nexport async function finalizeViteConfig(config: InlineConfig): Promise<InlineConfig> {\n if (typeof config.build?.rollupOptions?.input !== 'object') {\n throw new TypeError(\n 'Vite config must contain `build.rollupOptions.input`, and it must be an object',\n )\n }\n\n if (!config.root) {\n throw new Error(\n 'Vite config must contain `root` property, and must point to the Sanity root directory',\n )\n }\n\n return mergeConfig(config, {\n build: {\n rollupOptions: {\n input: {\n sanity: path.join(config.root, '.sanity', 'runtime', 'app.js'),\n },\n },\n },\n })\n}\n\n/**\n * Merge user-provided Vite configuration object or function\n *\n * @param defaultConfig - Default configuration object\n * @param userConfig - User-provided configuration object or function\n * @returns Merged configuration\n * @internal\n */\nexport async function extendViteConfigWithUserConfig(\n env: ConfigEnv,\n defaultConfig: InlineConfig,\n userConfig: UserViteConfig,\n): Promise<InlineConfig> {\n let config = defaultConfig\n\n if (typeof userConfig === 'function') {\n debug('Extending vite config using user-specified function')\n config = await userConfig(config, env)\n } else if (typeof userConfig === 'object') {\n debug('Merging vite config using user-specified object')\n config = mergeConfig(config, userConfig)\n }\n\n return config\n}\n"],"names":["path","findProjectRoot","getCliTelemetry","viteReact","debug","readPackageUp","mergeConfig","SANITY_CACHE_DIR","sanityBuildEntries","sanityFaviconsPlugin","sanityRuntimeRewritePlugin","sanitySchemaExtractionPlugin","sanityTypegenPlugin","createExternalFromImportMap","getAppEnvironmentVariables","getStudioEnvironmentVariables","normalizeBasePath","getViteConfig","options","autoUpdatesCssUrls","basePath","rawBasePath","cwd","importMap","isApp","minify","mode","outputDir","reactCompiler","schemaExtraction","server","sourceMap","typegen","sanityCliPkgPath","dirname","Error","configPath","customFaviconsPath","join","defaultFaviconsPath","staticPath","envVars","jsonEncode","prefix","viteConfig","base","build","outDir","resolve","sourcemap","cacheDir","configFile","define","__SANITY_BUILD_TIMESTAMP__","JSON","stringify","Date","now","__SANITY_STAGING__","process","env","SANITY_INTERNAL_ENV","PKG_BUILD_VERSION","envPrefix","logLevel","plugins","babel","generatorOpts","compact","staticUrlPath","enabled","additionalPatterns","watchPatterns","enforceRequiredFields","outputPath","telemetryLogger","workDir","workspaceName","workspace","config","dedupe","root","host","port","strictPort","warmup","clientFiles","assetsDir","emptyOutDir","rollupOptions","external","input","sanity","onwarn","onRollupWarn","warning","warn","suppressUnusedImport","code","names","includes","filter","n","length","ids","every","id","finalizeViteConfig","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QI,KAAK,CAACI,MAAM,KAAK,GAAG,OAAO;IACzC;IAEA,mFAAmF;IACnF,IAAIR,QAAQS,GAAG,EAAEC,MAAM,CAACC,KAAOA,GAAGN,QAAQ,CAAC,qBAAqBM,GAAGN,QAAQ,CAAC,sBAC1E,OAAO;IAET,OAAO;AACT;AAEA;;;;;;CAMC,GACD,OAAO,eAAeO,mBAAmB5B,MAAoB;IAC3D,IAAI,OAAOA,OAAOjC,KAAK,EAAE2C,eAAeE,UAAU,UAAU;QAC1D,MAAM,IAAIiB,UACR;IAEJ;IAEA,IAAI,CAAC7B,OAAOE,IAAI,EAAE;QAChB,MAAM,IAAI9C,MACR;IAEJ;IAEA,OAAO7B,YAAYyE,QAAQ;QACzBjC,OAAO;YACL2C,eAAe;gBACbE,OAAO;oBACLC,QAAQ5F,KAAKsC,IAAI,CAACyC,OAAOE,IAAI,EAAE,WAAW,WAAW;gBACvD;YACF;QACF;IACF;AACF;AAEA;;;;;;;CAOC,GACD,OAAO,eAAe4B,+BACpBjD,GAAc,EACdkD,aAA2B,EAC3BC,UAA0B;IAE1B,IAAIhC,SAAS+B;IAEb,IAAI,OAAOC,eAAe,YAAY;QACpC3G,MAAM;QACN2E,SAAS,MAAMgC,WAAWhC,QAAQnB;IACpC,OAAO,IAAI,OAAOmD,eAAe,UAAU;QACzC3G,MAAM;QACN2E,SAASzE,YAAYyE,QAAQgC;IAC/B;IAEA,OAAOhC;AACT"}
@@ -1,5 +1,5 @@
1
+ import { getLocalPackageVersion } from '@sanity/cli-core';
1
2
  import { compare } from 'semver';
2
- import { getLocalPackageVersion } from '../../util/getLocalPackageVersion.js';
3
3
  const purpose = 'Transform react-icons v2 imports to v3 form';
4
4
  const description = `
5
5
  Modifies all found react-icons import and require statements from their v2 form
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/codemods/reactIconsV3.ts"],"sourcesContent":["import {compare} from 'semver'\n\nimport {getLocalPackageVersion} from '../../util/getLocalPackageVersion.js'\nimport {type CodeMod} from './types.js'\n\nconst purpose = 'Transform react-icons v2 imports to v3 form'\nconst description = `\nModifies all found react-icons import and require statements from their v2 form\nto the path structure used in react-icons v3. For instance:\n\nfrom: import {MdPerson} from 'react-icons/lib/md'\n to: import {MdPerson} from 'react-icons/md'\n\nfrom: import PersonIcon from 'react-icons/lib/md/person'\n to: import {MdPerson as PersonIcon} from 'react-icons/md'\n`.trim()\n\nexport const reactIconsV3: CodeMod = {\n description,\n filename: 'reactIconsV3.js',\n purpose,\n verify: async (context) => {\n const {workDir} = context\n\n const dependencyVersion = await getLocalPackageVersion('react-icons', workDir)\n if (!dependencyVersion) {\n throw new Error('Could not find react-icons declared as dependency in package.json')\n }\n\n if (compare(dependencyVersion, '3.0.0') < 0) {\n throw new Error('react-icons declared in package.json dependencies is lower than 3.0.0')\n }\n },\n}\n"],"names":["compare","getLocalPackageVersion","purpose","description","trim","reactIconsV3","filename","verify","context","workDir","dependencyVersion","Error"],"mappings":"AAAA,SAAQA,OAAO,QAAO,SAAQ;AAE9B,SAAQC,sBAAsB,QAAO,uCAAsC;AAG3E,MAAMC,UAAU;AAChB,MAAMC,cAAc,CAAC;;;;;;;;;AASrB,CAAC,CAACC,IAAI;AAEN,OAAO,MAAMC,eAAwB;IACnCF;IACAG,UAAU;IACVJ;IACAK,QAAQ,OAAOC;QACb,MAAM,EAACC,OAAO,EAAC,GAAGD;QAElB,MAAME,oBAAoB,MAAMT,uBAAuB,eAAeQ;QACtE,IAAI,CAACC,mBAAmB;YACtB,MAAM,IAAIC,MAAM;QAClB;QAEA,IAAIX,QAAQU,mBAAmB,WAAW,GAAG;YAC3C,MAAM,IAAIC,MAAM;QAClB;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/actions/codemods/reactIconsV3.ts"],"sourcesContent":["import {getLocalPackageVersion} from '@sanity/cli-core'\nimport {compare} from 'semver'\n\nimport {type CodeMod} from './types.js'\n\nconst purpose = 'Transform react-icons v2 imports to v3 form'\nconst description = `\nModifies all found react-icons import and require statements from their v2 form\nto the path structure used in react-icons v3. For instance:\n\nfrom: import {MdPerson} from 'react-icons/lib/md'\n to: import {MdPerson} from 'react-icons/md'\n\nfrom: import PersonIcon from 'react-icons/lib/md/person'\n to: import {MdPerson as PersonIcon} from 'react-icons/md'\n`.trim()\n\nexport const reactIconsV3: CodeMod = {\n description,\n filename: 'reactIconsV3.js',\n purpose,\n verify: async (context) => {\n const {workDir} = context\n\n const dependencyVersion = await getLocalPackageVersion('react-icons', workDir)\n if (!dependencyVersion) {\n throw new Error('Could not find react-icons declared as dependency in package.json')\n }\n\n if (compare(dependencyVersion, '3.0.0') < 0) {\n throw new Error('react-icons declared in package.json dependencies is lower than 3.0.0')\n }\n },\n}\n"],"names":["getLocalPackageVersion","compare","purpose","description","trim","reactIconsV3","filename","verify","context","workDir","dependencyVersion","Error"],"mappings":"AAAA,SAAQA,sBAAsB,QAAO,mBAAkB;AACvD,SAAQC,OAAO,QAAO,SAAQ;AAI9B,MAAMC,UAAU;AAChB,MAAMC,cAAc,CAAC;;;;;;;;;AASrB,CAAC,CAACC,IAAI;AAEN,OAAO,MAAMC,eAAwB;IACnCF;IACAG,UAAU;IACVJ;IACAK,QAAQ,OAAOC;QACb,MAAM,EAACC,OAAO,EAAC,GAAGD;QAElB,MAAME,oBAAoB,MAAMV,uBAAuB,eAAeS;QACtE,IAAI,CAACC,mBAAmB;YACtB,MAAM,IAAIC,MAAM;QAClB;QAEA,IAAIV,QAAQS,mBAAmB,WAAW,GAAG;YAC3C,MAAM,IAAIC,MAAM;QAClB;IACF;AACF,EAAC"}
@@ -2,13 +2,13 @@ import { basename, dirname } from 'node:path';
2
2
  import { styleText } from 'node:util';
3
3
  import { createGzip } from 'node:zlib';
4
4
  import { CLIError } from '@oclif/core/errors';
5
+ import { getLocalPackageVersion } from '@sanity/cli-core';
5
6
  import { spinner } from '@sanity/cli-core/ux';
6
7
  import { pack } from 'tar-fs';
7
8
  import { createDeployment, updateUserApplication } from '../../services/userApplications.js';
8
9
  import { getAppId } from '../../util/appId.js';
9
10
  import { NO_ORGANIZATION_ID } from '../../util/errorMessages.js';
10
11
  import { getErrorMessage } from '../../util/getErrorMessage.js';
11
- import { getLocalPackageVersion } from '../../util/getLocalPackageVersion.js';
12
12
  import { buildApp } from '../build/buildApp.js';
13
13
  import { shouldAutoUpdate } from '../build/shouldAutoUpdate.js';
14
14
  import { extractAppManifest } from '../manifest/extractAppManifest.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/deploy/deployApp.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\nimport {styleText} from 'node:util'\nimport {createGzip} from 'node:zlib'\n\nimport {CLIError} from '@oclif/core/errors'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {pack} from 'tar-fs'\n\nimport {createDeployment, updateUserApplication} from '../../services/userApplications.js'\nimport {getAppId} from '../../util/appId.js'\nimport {NO_ORGANIZATION_ID} from '../../util/errorMessages.js'\nimport {getErrorMessage} from '../../util/getErrorMessage.js'\nimport {getLocalPackageVersion} from '../../util/getLocalPackageVersion.js'\nimport {buildApp} from '../build/buildApp.js'\nimport {shouldAutoUpdate} from '../build/shouldAutoUpdate.js'\nimport {extractAppManifest} from '../manifest/extractAppManifest.js'\nimport {type AppManifest} from '../manifest/types.js'\nimport {checkDir} from './checkDir.js'\nimport {createUserApplicationForApp} from './createUserApplicationForApp.js'\nimport {deployDebug} from './deployDebug.js'\nimport {findUserApplicationForApp} from './findUserApplicationForApp.js'\nimport {type DeployAppOptions} from './types.js'\n\n/**\n * Deploy a Sanity application.\n *\n * @internal\n */\nexport async function deployApp(options: DeployAppOptions) {\n const {cliConfig, flags, output, projectRoot, sourceDir} = options\n\n const workDir = projectRoot.directory\n\n const organizationId = cliConfig.app?.organizationId\n const appId = getAppId(cliConfig)\n const isAutoUpdating = shouldAutoUpdate({cliConfig, flags, output})\n const installedSdkVersion = await getLocalPackageVersion('@sanity/sdk-react', workDir)\n\n if (!installedSdkVersion) {\n output.error(`Failed to find installed @sanity/sdk-react version`, {exit: 1})\n return\n }\n\n if (!organizationId) {\n output.error(NO_ORGANIZATION_ID, {exit: 1})\n return\n }\n\n if (flags.external) {\n output.error('Deploying an app to an external host is not supported.', {exit: 1})\n }\n\n let spin = spinner('Verifying local content...')\n\n try {\n let userApplication = await findUserApplicationForApp({\n cliConfig,\n organizationId,\n output,\n })\n\n deployDebug(`User application found`, userApplication)\n\n if (!userApplication) {\n deployDebug(`No user application found. Creating a new one`)\n\n userApplication = await createUserApplicationForApp(organizationId)\n deployDebug(`User application created`, userApplication)\n }\n\n // Always build the project, unless --no-build is passed\n const shouldBuild = flags.build\n if (shouldBuild) {\n deployDebug(`Building app`)\n await buildApp({\n autoUpdatesEnabled: isAutoUpdating,\n calledFromDeploy: true,\n cliConfig,\n flags,\n outDir: sourceDir,\n output,\n workDir,\n })\n }\n\n // Ensure that the directory exists, is a directory and seems to have valid content\n spin = spin.start()\n try {\n await checkDir(sourceDir)\n spin.succeed()\n } catch (err) {\n spin.fail()\n deployDebug('Error checking directory', err)\n output.error('Error checking directory', {exit: 1})\n return\n }\n\n // Create a tarball of the given directory\n const parentDir = dirname(sourceDir)\n const base = basename(sourceDir)\n const tarball = pack(parentDir, {entries: [base]}).pipe(createGzip())\n let manifest: AppManifest | undefined\n try {\n manifest = await extractAppManifest({workDir})\n } catch (err) {\n deployDebug('Error extracting app manifest', err)\n const message = getErrorMessage(err)\n // manifests aren't strictly essential, so continue deploy\n output.warn(`Error extracting app manifest: ${message}`)\n }\n\n // Sync app title from manifest when it has changed (Brett user-applications)\n if (manifest?.title !== undefined && manifest.title !== userApplication.title) {\n deployDebug('Updating application title from manifest', {\n from: userApplication.title,\n to: manifest.title,\n })\n const existing = userApplication.title\n output.log(\n existing\n ? `Updating title from \"${existing}\" to \"${manifest.title}\"`\n : `Setting application title to \"${manifest.title}\"`,\n )\n spin = spinner(`Updating application title`).start()\n try {\n userApplication = await updateUserApplication({\n applicationId: userApplication.id,\n appType: 'coreApp',\n body: {title: manifest.title},\n })\n spin.succeed()\n } catch (err) {\n spin.fail()\n const message = getErrorMessage(err)\n deployDebug('Error updating application title', {message})\n output.warn(`Error updating application title: ${message}`)\n }\n }\n\n spin = spinner('Deploying...').start()\n await createDeployment({\n applicationId: userApplication.id,\n isApp: true,\n isAutoUpdating,\n manifest,\n tarball,\n version: installedSdkVersion,\n })\n\n spin.succeed()\n\n // And let the user know we're done\n output.log(`\\n🚀 ${styleText('bold', 'Success!')} Application deployed`)\n\n if (!appId) {\n output.log(`\\n════ ${styleText('bold', 'Next step:')} ════`)\n output.log(\n styleText(\n 'bold',\n '\\nAdd the deployment.appId to your sanity.cli.js or sanity.cli.ts file:',\n ),\n )\n output.log(`\n${styleText(\n 'dim',\n `app: {\n // your application config here…\n}`,\n)},\n${styleText(\n ['bold', 'green'],\n `deployment: {\n appId: '${userApplication.id}',\n}\\n`,\n)}`)\n }\n } catch (error) {\n spin.clear()\n // Don't throw generic error if user cancels\n if (error.name === 'ExitPromptError') {\n output.error('Deployment cancelled by user', {exit: 1})\n return\n }\n // If the error is a CLIError, we can just output the message & error options (if any), while ensuring we exit\n if (error instanceof CLIError) {\n const {message, ...errorOptions} = error\n output.error(message, {...errorOptions, exit: 1})\n return\n }\n\n deployDebug('Error deploying application', error)\n output.error(`Error deploying application: ${error}`, {exit: 1})\n }\n}\n"],"names":["basename","dirname","styleText","createGzip","CLIError","spinner","pack","createDeployment","updateUserApplication","getAppId","NO_ORGANIZATION_ID","getErrorMessage","getLocalPackageVersion","buildApp","shouldAutoUpdate","extractAppManifest","checkDir","createUserApplicationForApp","deployDebug","findUserApplicationForApp","deployApp","options","cliConfig","flags","output","projectRoot","sourceDir","workDir","directory","organizationId","app","appId","isAutoUpdating","installedSdkVersion","error","exit","external","spin","userApplication","shouldBuild","build","autoUpdatesEnabled","calledFromDeploy","outDir","start","succeed","err","fail","parentDir","base","tarball","entries","pipe","manifest","message","warn","title","undefined","from","to","existing","log","applicationId","id","appType","body","isApp","version","clear","name","errorOptions"],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AG,CAAC,CAAC;AAClB,EAAE3D,UACA,OACA,CAAC;;CAEF,CAAC,EACA;AACF,EAAEA,UACA;gBAAC;gBAAQ;aAAQ,EACjB,CAAC;UACO,EAAEoC,gBAAgByB,EAAE,CAAC;GAC5B,CAAC,GACD;QACC;IACF,EAAE,OAAO7B,OAAO;QACdG,KAAK+B,KAAK;QACV,4CAA4C;QAC5C,IAAIlC,MAAMmC,IAAI,KAAK,mBAAmB;YACpC7C,OAAOU,KAAK,CAAC,gCAAgC;gBAACC,MAAM;YAAC;YACrD;QACF;QACA,8GAA8G;QAC9G,IAAID,iBAAiB9B,UAAU;YAC7B,MAAM,EAACkD,OAAO,EAAE,GAAGgB,cAAa,GAAGpC;YACnCV,OAAOU,KAAK,CAACoB,SAAS;gBAAC,GAAGgB,YAAY;gBAAEnC,MAAM;YAAC;YAC/C;QACF;QAEAjB,YAAY,+BAA+BgB;QAC3CV,OAAOU,KAAK,CAAC,CAAC,6BAA6B,EAAEA,OAAO,EAAE;YAACC,MAAM;QAAC;IAChE;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/deploy/deployApp.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\nimport {styleText} from 'node:util'\nimport {createGzip} from 'node:zlib'\n\nimport {CLIError} from '@oclif/core/errors'\nimport {getLocalPackageVersion} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {pack} from 'tar-fs'\n\nimport {createDeployment, updateUserApplication} from '../../services/userApplications.js'\nimport {getAppId} from '../../util/appId.js'\nimport {NO_ORGANIZATION_ID} from '../../util/errorMessages.js'\nimport {getErrorMessage} from '../../util/getErrorMessage.js'\nimport {buildApp} from '../build/buildApp.js'\nimport {shouldAutoUpdate} from '../build/shouldAutoUpdate.js'\nimport {extractAppManifest} from '../manifest/extractAppManifest.js'\nimport {type CoreAppManifest} from '../manifest/types.js'\nimport {checkDir} from './checkDir.js'\nimport {createUserApplicationForApp} from './createUserApplicationForApp.js'\nimport {deployDebug} from './deployDebug.js'\nimport {findUserApplicationForApp} from './findUserApplicationForApp.js'\nimport {type DeployAppOptions} from './types.js'\n\n/**\n * Deploy a Sanity application.\n *\n * @internal\n */\nexport async function deployApp(options: DeployAppOptions) {\n const {cliConfig, flags, output, projectRoot, sourceDir} = options\n\n const workDir = projectRoot.directory\n\n const organizationId = cliConfig.app?.organizationId\n const appId = getAppId(cliConfig)\n const isAutoUpdating = shouldAutoUpdate({cliConfig, flags, output})\n const installedSdkVersion = await getLocalPackageVersion('@sanity/sdk-react', workDir)\n\n if (!installedSdkVersion) {\n output.error(`Failed to find installed @sanity/sdk-react version`, {exit: 1})\n return\n }\n\n if (!organizationId) {\n output.error(NO_ORGANIZATION_ID, {exit: 1})\n return\n }\n\n if (flags.external) {\n output.error('Deploying an app to an external host is not supported.', {exit: 1})\n }\n\n let spin = spinner('Verifying local content...')\n\n try {\n let userApplication = await findUserApplicationForApp({\n cliConfig,\n organizationId,\n output,\n })\n\n deployDebug(`User application found`, userApplication)\n\n if (!userApplication) {\n deployDebug(`No user application found. Creating a new one`)\n\n userApplication = await createUserApplicationForApp(organizationId)\n deployDebug(`User application created`, userApplication)\n }\n\n // Always build the project, unless --no-build is passed\n const shouldBuild = flags.build\n if (shouldBuild) {\n deployDebug(`Building app`)\n await buildApp({\n autoUpdatesEnabled: isAutoUpdating,\n calledFromDeploy: true,\n cliConfig,\n flags,\n outDir: sourceDir,\n output,\n workDir,\n })\n }\n\n // Ensure that the directory exists, is a directory and seems to have valid content\n spin = spin.start()\n try {\n await checkDir(sourceDir)\n spin.succeed()\n } catch (err) {\n spin.fail()\n deployDebug('Error checking directory', err)\n output.error('Error checking directory', {exit: 1})\n return\n }\n\n // Create a tarball of the given directory\n const parentDir = dirname(sourceDir)\n const base = basename(sourceDir)\n const tarball = pack(parentDir, {entries: [base]}).pipe(createGzip())\n let manifest: CoreAppManifest | undefined\n try {\n manifest = await extractAppManifest({workDir})\n } catch (err) {\n deployDebug('Error extracting app manifest', err)\n const message = getErrorMessage(err)\n // manifests aren't strictly essential, so continue deploy\n output.warn(`Error extracting app manifest: ${message}`)\n }\n\n // Sync app title from manifest when it has changed (Brett user-applications)\n if (manifest?.title !== undefined && manifest.title !== userApplication.title) {\n deployDebug('Updating application title from manifest', {\n from: userApplication.title,\n to: manifest.title,\n })\n const existing = userApplication.title\n output.log(\n existing\n ? `Updating title from \"${existing}\" to \"${manifest.title}\"`\n : `Setting application title to \"${manifest.title}\"`,\n )\n spin = spinner(`Updating application title`).start()\n try {\n userApplication = await updateUserApplication({\n applicationId: userApplication.id,\n appType: 'coreApp',\n body: {title: manifest.title},\n })\n spin.succeed()\n } catch (err) {\n spin.fail()\n const message = getErrorMessage(err)\n deployDebug('Error updating application title', {message})\n output.warn(`Error updating application title: ${message}`)\n }\n }\n\n spin = spinner('Deploying...').start()\n await createDeployment({\n applicationId: userApplication.id,\n isApp: true,\n isAutoUpdating,\n manifest,\n tarball,\n version: installedSdkVersion,\n })\n\n spin.succeed()\n\n // And let the user know we're done\n output.log(`\\n🚀 ${styleText('bold', 'Success!')} Application deployed`)\n\n if (!appId) {\n output.log(`\\n════ ${styleText('bold', 'Next step:')} ════`)\n output.log(\n styleText(\n 'bold',\n '\\nAdd the deployment.appId to your sanity.cli.js or sanity.cli.ts file:',\n ),\n )\n output.log(`\n${styleText(\n 'dim',\n `app: {\n // your application config here…\n}`,\n)},\n${styleText(\n ['bold', 'green'],\n `deployment: {\n appId: '${userApplication.id}',\n}\\n`,\n)}`)\n }\n } catch (error) {\n spin.clear()\n // Don't throw generic error if user cancels\n if (error.name === 'ExitPromptError') {\n output.error('Deployment cancelled by user', {exit: 1})\n return\n }\n // If the error is a CLIError, we can just output the message & error options (if any), while ensuring we exit\n if (error instanceof CLIError) {\n const {message, ...errorOptions} = error\n output.error(message, {...errorOptions, exit: 1})\n return\n }\n\n deployDebug('Error deploying application', error)\n output.error(`Error deploying application: ${error}`, {exit: 1})\n }\n}\n"],"names":["basename","dirname","styleText","createGzip","CLIError","getLocalPackageVersion","spinner","pack","createDeployment","updateUserApplication","getAppId","NO_ORGANIZATION_ID","getErrorMessage","buildApp","shouldAutoUpdate","extractAppManifest","checkDir","createUserApplicationForApp","deployDebug","findUserApplicationForApp","deployApp","options","cliConfig","flags","output","projectRoot","sourceDir","workDir","directory","organizationId","app","appId","isAutoUpdating","installedSdkVersion","error","exit","external","spin","userApplication","shouldBuild","build","autoUpdatesEnabled","calledFromDeploy","outDir","start","succeed","err","fail","parentDir","base","tarball","entries","pipe","manifest","message","warn","title","undefined","from","to","existing","log","applicationId","id","appType","body","isApp","version","clear","name","errorOptions"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAC3C,SAAQC,SAAS,QAAO,YAAW;AACnC,SAAQC,UAAU,QAAO,YAAW;AAEpC,SAAQC,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,sBAAsB,QAAO,mBAAkB;AACvD,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,IAAI,QAAO,SAAQ;AAE3B,SAAQC,gBAAgB,EAAEC,qBAAqB,QAAO,qCAAoC;AAC1F,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,kBAAkB,QAAO,8BAA6B;AAC9D,SAAQC,eAAe,QAAO,gCAA+B;AAC7D,SAAQC,QAAQ,QAAO,uBAAsB;AAC7C,SAAQC,gBAAgB,QAAO,+BAA8B;AAC7D,SAAQC,kBAAkB,QAAO,oCAAmC;AAEpE,SAAQC,QAAQ,QAAO,gBAAe;AACtC,SAAQC,2BAA2B,QAAO,mCAAkC;AAC5E,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAAQC,yBAAyB,QAAO,iCAAgC;AAGxE;;;;CAIC,GACD,OAAO,eAAeC,UAAUC,OAAyB;IACvD,MAAM,EAACC,SAAS,EAAEC,KAAK,EAAEC,MAAM,EAAEC,WAAW,EAAEC,SAAS,EAAC,GAAGL;IAE3D,MAAMM,UAAUF,YAAYG,SAAS;IAErC,MAAMC,i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YACrBsD,eAAexB,gBAAgByB,EAAE;YACjCG,OAAO;YACPlC;YACAqB;YACAH;YACAiB,SAASlC;QACX;QAEAI,KAAKQ,OAAO;QAEZ,mCAAmC;QACnCrB,OAAOqC,GAAG,CAAC,CAAC,KAAK,EAAE3D,UAAU,QAAQ,YAAY,qBAAqB,CAAC;QAEvE,IAAI,CAAC6B,OAAO;YACVP,OAAOqC,GAAG,CAAC,CAAC,OAAO,EAAE3D,UAAU,QAAQ,cAAc,KAAK,CAAC;YAC3DsB,OAAOqC,GAAG,CACR3D,UACE,QACA;YAGJsB,OAAOqC,GAAG,CAAC,CAAC;AAClB,EAAE3D,UACA,OACA,CAAC;;CAEF,CAAC,EACA;AACF,EAAEA,UACA;gBAAC;gBAAQ;aAAQ,EACjB,CAAC;UACO,EAAEoC,gBAAgByB,EAAE,CAAC;GAC5B,CAAC,GACD;QACC;IACF,EAAE,OAAO7B,OAAO;QACdG,KAAK+B,KAAK;QACV,4CAA4C;QAC5C,IAAIlC,MAAMmC,IAAI,KAAK,mBAAmB;YACpC7C,OAAOU,KAAK,CAAC,gCAAgC;gBAACC,MAAM;YAAC;YACrD;QACF;QACA,8GAA8G;QAC9G,IAAID,iBAAiB9B,UAAU;YAC7B,MAAM,EAACkD,OAAO,EAAE,GAAGgB,cAAa,GAAGpC;YACnCV,OAAOU,KAAK,CAACoB,SAAS;gBAAC,GAAGgB,YAAY;gBAAEnC,MAAM;YAAC;YAC/C;QACF;QAEAjB,YAAY,+BAA+BgB;QAC3CV,OAAOU,KAAK,CAAC,CAAC,6BAA6B,EAAEA,OAAO,EAAE;YAACC,MAAM;QAAC;IAChE;AACF"}
@@ -2,13 +2,12 @@ import { basename, dirname } from 'node:path';
2
2
  import { styleText } from 'node:util';
3
3
  import { createGzip } from 'node:zlib';
4
4
  import { CLIError } from '@oclif/core/errors';
5
- import { exitCodes } from '@sanity/cli-core';
5
+ import { exitCodes, getLocalPackageVersion } from '@sanity/cli-core';
6
6
  import { spinner } from '@sanity/cli-core/ux';
7
7
  import { pack } from 'tar-fs';
8
8
  import { createDeployment } from '../../services/userApplications.js';
9
9
  import { getAppId } from '../../util/appId.js';
10
10
  import { NO_PROJECT_ID } from '../../util/errorMessages.js';
11
- import { getLocalPackageVersion } from '../../util/getLocalPackageVersion.js';
12
11
  import { buildStudio } from '../build/buildStudio.js';
13
12
  import { shouldAutoUpdate } from '../build/shouldAutoUpdate.js';
14
13
  import { formatSchemaValidation } from '../schema/formatSchemaValidation.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/deploy/deployStudio.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\nimport {styleText} from 'node:util'\nimport {createGzip, type Gzip} from 'node:zlib'\n\nimport {CLIError} from '@oclif/core/errors'\nimport {exitCodes, type Output} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {type StudioManifest} from 'sanity'\nimport {pack} from 'tar-fs'\n\nimport {createDeployment} from '../../services/userApplications.js'\nimport {getAppId} from '../../util/appId.js'\nimport {NO_PROJECT_ID} from '../../util/errorMessages.js'\nimport {getLocalPackageVersion} from '../../util/getLocalPackageVersion.js'\nimport {buildStudio} from '../build/buildStudio.js'\nimport {shouldAutoUpdate} from '../build/shouldAutoUpdate.js'\nimport {formatSchemaValidation} from '../schema/formatSchemaValidation.js'\nimport {SchemaExtractionError} from '../schema/utils/SchemaExtractionError.js'\nimport {checkDir} from './checkDir.js'\nimport {createStudioUserApplication} from './createStudioUserApplication.js'\nimport {deployDebug} from './deployDebug.js'\nimport {deployStudioSchemasAndManifests} from './deployStudioSchemasAndManifests.js'\nimport {findUserApplicationForStudio} from './findUserApplicationForStudio.js'\nimport {type DeployAppOptions} from './types.js'\nimport {normalizeUrl, validateUrl} from './urlUtils.js'\n\nexport async function deployStudio(options: DeployAppOptions) {\n const {cliConfig, flags, output, projectRoot, sourceDir} = options\n\n const workDir = projectRoot.directory\n const configPath = projectRoot.path\n\n const appId = getAppId(cliConfig)\n const projectId = cliConfig.api?.projectId\n const installedSanityVersion = await getLocalPackageVersion('sanity', workDir)\n const isAutoUpdating = shouldAutoUpdate({cliConfig, flags, output})\n\n const isExternal = !!flags.external\n const urlType: 'external' | 'internal' = isExternal ? 'external' : 'internal'\n\n // Resolve the app host from --url flag (takes precedence) or studioHost config\n const appHost = resolveAppHost({flags, isExternal, output, studioHost: cliConfig.studioHost})\n\n if (!installedSanityVersion) {\n output.error(`Failed to find installed sanity version`, {exit: 1})\n return\n }\n\n if (!projectId) {\n output.error(NO_PROJECT_ID, {exit: 1})\n return\n }\n\n let spin = spinner('Verifying local content')\n\n try {\n let userApplication = await findUserApplicationForStudio({\n appHost,\n appId,\n output,\n projectId,\n unattended: !!flags.yes,\n urlType,\n })\n\n if (!userApplication) {\n if (flags.yes) {\n const flagHint = isExternal\n ? 'Use --url to specify the external studio URL'\n : 'Use --url to specify the studio hostname'\n output.error(\n `Cannot prompt for ${isExternal ? 'external studio URL' : 'studio hostname'} in unattended mode. ${flagHint}.`,\n {exit: exitCodes.USAGE_ERROR},\n )\n return\n }\n\n if (isExternal) {\n output.log('Your project has not been registered with an external studio URL.')\n output.log('Please enter the full URL where your studio is hosted.')\n } else {\n output.log('Your project has not been assigned a studio hostname.')\n output.log('To deploy your Sanity Studio to our hosted sanity.studio service,')\n output.log('you will need one. Please enter the subdomain you want to use.')\n }\n\n userApplication = await createStudioUserApplication({projectId, urlType})\n\n deployDebug('Created user application', userApplication)\n }\n\n deployDebug('Found user application', userApplication)\n\n // Always build the project, unless --no-build is passed or --external is passed\n const shouldBuild = flags.build && !isExternal\n if (shouldBuild) {\n deployDebug(`Building studio`)\n await buildStudio({\n autoUpdatesEnabled: isAutoUpdating,\n calledFromDeploy: true,\n cliConfig,\n flags,\n outDir: sourceDir,\n output,\n workDir,\n })\n }\n\n let studioManifest: StudioManifest | null = null\n try {\n studioManifest = await deployStudioSchemasAndManifests({\n configPath,\n isExternal,\n outPath: `${sourceDir}/static`,\n projectId,\n schemaRequired: flags['schema-required'],\n verbose: flags.verbose,\n workDir,\n })\n } catch (error) {\n deployDebug('Error deploying studio schemas and manifests', error)\n if (error instanceof SchemaExtractionError) {\n output.error(formatSchemaValidation(error.validation || []), {exit: 1})\n }\n output.error(`Error deploying studio schemas and manifests: ${error}`, {exit: 1})\n }\n\n if (!studioManifest) {\n output.error('Failed to generate studio manifest. Please check your schemas and manifests.', {\n exit: 1,\n })\n }\n\n let tarball: Gzip | undefined\n\n if (!isExternal) {\n // Ensure that the directory exists, is a directory and seems to have valid content\n spin = spin.start()\n try {\n await checkDir(sourceDir)\n spin.succeed()\n } catch (err) {\n spin.fail()\n deployDebug('Error checking directory', err)\n output.error('Error checking directory', {exit: 1})\n }\n\n // Create a tarball of the given directory\n const parentDir = dirname(sourceDir)\n const base = basename(sourceDir)\n tarball = pack(parentDir, {entries: [base]}).pipe(createGzip())\n }\n\n spin = spinner(isExternal ? 'Registering studio' : 'Deploying to sanity.studio').start()\n\n const {location} = await createDeployment({\n applicationId: userApplication.id,\n isApp: false,\n isAutoUpdating,\n manifest: studioManifest,\n projectId,\n tarball,\n version: installedSanityVersion,\n })\n\n spin.succeed()\n\n if (isExternal) {\n output.log(`\\nSuccess! Studio registered`)\n } else {\n output.log(`\\nSuccess! Studio deployed to ${styleText('cyan', location)}`)\n }\n\n if (!appId) {\n const example = `Example:\nexport default defineCliConfig({\n //…\n deployment: {\n ${styleText('cyan', `appId: '${userApplication.id}'`)},\n },\n //…\n})`\n output.log(`\\nAdd ${styleText('cyan', `appId: '${userApplication.id}'`)}`)\n output.log(`to the \\`deployment\\` section in sanity.cli.js or sanity.cli.ts`)\n output.log(`to avoid prompting for application id on next deploy.`)\n output.log(`\\n${example}`)\n }\n } catch (error) {\n // if the error is a CLIError, we can just output the message and preserve its exit code\n if (error instanceof CLIError) {\n output.error(error.message, {exit: error.oclif?.exit ?? exitCodes.RUNTIME_ERROR})\n return\n }\n\n spin.fail()\n deployDebug('Error deploying studio', error)\n output.error(`Error deploying studio: ${error}`, {exit: 1})\n }\n}\n\nfunction resolveAppHost({\n flags,\n isExternal,\n output,\n studioHost,\n}: {\n flags: DeployAppOptions['flags']\n isExternal: boolean\n output: Output\n studioHost: string | undefined\n}): string | undefined {\n const url = flags.url\n if (!url) {\n return studioHost\n }\n\n if (isExternal) {\n const normalized = normalizeUrl(url)\n const validation = validateUrl(normalized)\n if (validation !== true) {\n output.error(validation, {exit: exitCodes.USAGE_ERROR})\n return undefined\n }\n return normalized\n }\n\n // For internal deploys, strip protocol prefix and .sanity.studio suffix if present\n const hostname = url.replace(/^https?:\\/\\//i, '').replace(/\\.sanity\\.studio\\/?$/i, '')\n\n // If the result still looks like a URL (contains dots), the user likely meant --external\n if (hostname.includes('.')) {\n output.error(\n `\"${hostname}\" does not look like a sanity.studio hostname. Did you mean to use --external?`,\n {exit: exitCodes.USAGE_ERROR},\n )\n return undefined\n }\n\n // Validate hostname characters (alphanumeric and hyphens only)\n if (!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/i.test(hostname)) {\n output.error(\n `Invalid studio hostname \"${hostname}\". Hostnames can only contain letters, numbers, and hyphens.`,\n {exit: exitCodes.USAGE_ERROR},\n )\n return undefined\n }\n\n return hostname\n}\n"],"names":["basename","dirname","styleText","createGzip","CLIError","exitCodes","spinner","pack","createDeployment","getAppId","NO_PROJECT_ID","getLocalPackageVersion","buildStudio","shouldAutoUpdate","formatSchemaValidation","SchemaExtractionError","checkDir","createStudioUserApplication","deployDebug","deployStudioSchemasAndManifests","findUserApplicationForStudio","normalizeUrl","validateUrl","deployStudio","options","cliConfig","flags","output","projectRoot","sourceDir","workDir","directory","configPath","path","appId","projectId","api","installedSanityVersion","isAutoUpdating","isExternal","external","urlType","appHost","resolveAppHost","studioHost","error","exit","spin","userApplication","unattended","yes","flagHint","USAGE_ERROR","log","shouldBuild","build","autoUpdatesEnabled","calledFromDeploy","outDir","studioManifest","outPath","schemaRequired","verbose","validation","tarball","start","succeed","err","fail","parentDir","base","entries","pipe","location","applicationId","id","isApp","manifest","version","example","message","oclif","RUNTIME_ERROR","url","normalized","undefined","hostname","replace","includes","test"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAC3C,SAAQC,SAAS,QAAO,YAAW;AACnC,SAAQC,UAAU,QAAkB,YAAW;AAE/C,SAAQC,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,SAAS,QAAoB,mBAAkB;AACvD,SAAQC,OAAO,QAAO,sBAAqB;AAE3C,SAAQC,IAAI,QAAO,SAAQ;AAE3B,SAAQC,gBAAgB,QAAO,qCAAoC;AACnE,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,aAAa,QAAO,8BAA6B;AACzD,SAAQC,sBAAsB,QAAO,uCAAsC;AAC3E,SAAQC,WAAW,QAAO,0BAAyB;AACnD,SAAQC,gBAAgB,QAAO,+BAA8B;AAC7D,SAAQC,sBAAsB,QAAO,sCAAqC;AAC1E,SAAQC,qBAAqB,QAAO,2CAA0C;AAC9E,SAAQC,QAAQ,QAAO,gBAAe;AACtC,SAAQC,2BAA2B,QAAO,mCAAkC;AAC5E,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAAQC,+BAA+B,QAAO,uCAAsC;AACpF,SAAQC,4BAA4B,QAAO,oCAAmC;AAE9E,SAAQC,YAAY,EAAEC,WAAW,QAAO,gBAAe;AAEvD,OAAO,eAAeC,aAAaC,OAAyB;IAC1D,MAAM,EAACC,SAAS,EAAEC,KAAK,EAAEC,MAAM,EAAEC,WAAW,EAAEC,SAAS,EAAC,GAAGL;IAE3D,MAAMM,UAAUF,YAAYG,SAAS;IACrC,MAAMC,aAAaJ,YAAYK,IAAI;IAEnC,MAAMC,QAAQzB,SAASgB;IACvB,MAAMU,YAAYV,UAAUW,GAAG,EAAED;IACjC,MAAME,yBAAyB,MAAM1B,uBAAuB,UAAUmB;IACtE,MAAMQ,iBAAiBzB,iBAAiB;QAACY;QAAWC;QAAOC;IAAM;IAEjE,MAAMY,aAAa,CAAC,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C,aAAa/D,aAAa8D;QAChC,MAAMpB,aAAazC,YAAY8D;QAC/B,IAAIrB,eAAe,MAAM;YACvBpC,OAAOkB,KAAK,CAACkB,YAAY;gBAACjB,MAAMzC,UAAU+C,WAAW;YAAA;YACrD,OAAOiC;QACT;QACA,OAAOD;IACT;IAEA,mFAAmF;IACnF,MAAME,WAAWH,IAAII,OAAO,CAAC,iBAAiB,IAAIA,OAAO,CAAC,yBAAyB;IAEnF,yFAAyF;IACzF,IAAID,SAASE,QAAQ,CAAC,MAAM;QAC1B7D,OAAOkB,KAAK,CACV,CAAC,CAAC,EAAEyC,SAAS,8EAA8E,CAAC,EAC5F;YAACxC,MAAMzC,UAAU+C,WAAW;QAAA;QAE9B,OAAOiC;IACT;IAEA,+DAA+D;IAC/D,IAAI,CAAC,mCAAmCI,IAAI,CAACH,WAAW;QACtD3D,OAAOkB,KAAK,CACV,CAAC,yBAAyB,EAAEyC,SAAS,4DAA4D,CAAC,EAClG;YAACxC,MAAMzC,UAAU+C,WAAW;QAAA;QAE9B,OAAOiC;IACT;IAEA,OAAOC;AACT"}
1
+ {"version":3,"sources":["../../../src/actions/deploy/deployStudio.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\nimport {styleText} from 'node:util'\nimport {createGzip, type Gzip} from 'node:zlib'\n\nimport {CLIError} from '@oclif/core/errors'\nimport {exitCodes, getLocalPackageVersion, type Output} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {type StudioManifest} from 'sanity'\nimport {pack} from 'tar-fs'\n\nimport {createDeployment} from '../../services/userApplications.js'\nimport {getAppId} from '../../util/appId.js'\nimport {NO_PROJECT_ID} from '../../util/errorMessages.js'\nimport {buildStudio} from '../build/buildStudio.js'\nimport {shouldAutoUpdate} from '../build/shouldAutoUpdate.js'\nimport {formatSchemaValidation} from '../schema/formatSchemaValidation.js'\nimport {SchemaExtractionError} from '../schema/utils/SchemaExtractionError.js'\nimport {checkDir} from './checkDir.js'\nimport {createStudioUserApplication} from './createStudioUserApplication.js'\nimport {deployDebug} from './deployDebug.js'\nimport {deployStudioSchemasAndManifests} from './deployStudioSchemasAndManifests.js'\nimport {findUserApplicationForStudio} from './findUserApplicationForStudio.js'\nimport {type DeployAppOptions} from './types.js'\nimport {normalizeUrl, validateUrl} from './urlUtils.js'\n\nexport async function deployStudio(options: DeployAppOptions) {\n const {cliConfig, flags, output, projectRoot, sourceDir} = options\n\n const workDir = projectRoot.directory\n const configPath = projectRoot.path\n\n const appId = getAppId(cliConfig)\n const projectId = cliConfig.api?.projectId\n const installedSanityVersion = await getLocalPackageVersion('sanity', workDir)\n const isAutoUpdating = shouldAutoUpdate({cliConfig, flags, output})\n\n const isExternal = !!flags.external\n const urlType: 'external' | 'internal' = isExternal ? 'external' : 'internal'\n\n // Resolve the app host from --url flag (takes precedence) or studioHost config\n const appHost = resolveAppHost({flags, isExternal, output, studioHost: cliConfig.studioHost})\n\n if (!installedSanityVersion) {\n output.error(`Failed to find installed sanity version`, {exit: 1})\n return\n }\n\n if (!projectId) {\n output.error(NO_PROJECT_ID, {exit: 1})\n return\n }\n\n let spin = spinner('Verifying local content')\n\n try {\n let userApplication = await findUserApplicationForStudio({\n appHost,\n appId,\n output,\n projectId,\n unattended: !!flags.yes,\n urlType,\n })\n\n if (!userApplication) {\n if (flags.yes) {\n const flagHint = isExternal\n ? 'Use --url to specify the external studio URL'\n : 'Use --url to specify the studio hostname'\n output.error(\n `Cannot prompt for ${isExternal ? 'external studio URL' : 'studio hostname'} in unattended mode. ${flagHint}.`,\n {exit: exitCodes.USAGE_ERROR},\n )\n return\n }\n\n if (isExternal) {\n output.log('Your project has not been registered with an external studio URL.')\n output.log('Please enter the full URL where your studio is hosted.')\n } else {\n output.log('Your project has not been assigned a studio hostname.')\n output.log('To deploy your Sanity Studio to our hosted sanity.studio service,')\n output.log('you will need one. Please enter the subdomain you want to use.')\n }\n\n userApplication = await createStudioUserApplication({projectId, urlType})\n\n deployDebug('Created user application', userApplication)\n }\n\n deployDebug('Found user application', userApplication)\n\n // Always build the project, unless --no-build is passed or --external is passed\n const shouldBuild = flags.build && !isExternal\n if (shouldBuild) {\n deployDebug(`Building studio`)\n await buildStudio({\n autoUpdatesEnabled: isAutoUpdating,\n calledFromDeploy: true,\n cliConfig,\n flags,\n outDir: sourceDir,\n output,\n workDir,\n })\n }\n\n let studioManifest: StudioManifest | null = null\n try {\n studioManifest = await deployStudioSchemasAndManifests({\n configPath,\n isExternal,\n outPath: `${sourceDir}/static`,\n projectId,\n schemaRequired: flags['schema-required'],\n verbose: flags.verbose,\n workDir,\n })\n } catch (error) {\n deployDebug('Error deploying studio schemas and manifests', error)\n if (error instanceof SchemaExtractionError) {\n output.error(formatSchemaValidation(error.validation || []), {exit: 1})\n }\n output.error(`Error deploying studio schemas and manifests: ${error}`, {exit: 1})\n }\n\n if (!studioManifest) {\n output.error('Failed to generate studio manifest. Please check your schemas and manifests.', {\n exit: 1,\n })\n }\n\n let tarball: Gzip | undefined\n\n if (!isExternal) {\n // Ensure that the directory exists, is a directory and seems to have valid content\n spin = spin.start()\n try {\n await checkDir(sourceDir)\n spin.succeed()\n } catch (err) {\n spin.fail()\n deployDebug('Error checking directory', err)\n output.error('Error checking directory', {exit: 1})\n }\n\n // Create a tarball of the given directory\n const parentDir = dirname(sourceDir)\n const base = basename(sourceDir)\n tarball = pack(parentDir, {entries: [base]}).pipe(createGzip())\n }\n\n spin = spinner(isExternal ? 'Registering studio' : 'Deploying to sanity.studio').start()\n\n const {location} = await createDeployment({\n applicationId: userApplication.id,\n isApp: false,\n isAutoUpdating,\n manifest: studioManifest,\n projectId,\n tarball,\n version: installedSanityVersion,\n })\n\n spin.succeed()\n\n if (isExternal) {\n output.log(`\\nSuccess! Studio registered`)\n } else {\n output.log(`\\nSuccess! Studio deployed to ${styleText('cyan', location)}`)\n }\n\n if (!appId) {\n const example = `Example:\nexport default defineCliConfig({\n //…\n deployment: {\n ${styleText('cyan', `appId: '${userApplication.id}'`)},\n },\n //…\n})`\n output.log(`\\nAdd ${styleText('cyan', `appId: '${userApplication.id}'`)}`)\n output.log(`to the \\`deployment\\` section in sanity.cli.js or sanity.cli.ts`)\n output.log(`to avoid prompting for application id on next deploy.`)\n output.log(`\\n${example}`)\n }\n } catch (error) {\n // if the error is a CLIError, we can just output the message and preserve its exit code\n if (error instanceof CLIError) {\n output.error(error.message, {exit: error.oclif?.exit ?? exitCodes.RUNTIME_ERROR})\n return\n }\n\n spin.fail()\n deployDebug('Error deploying studio', error)\n output.error(`Error deploying studio: ${error}`, {exit: 1})\n }\n}\n\nfunction resolveAppHost({\n flags,\n isExternal,\n output,\n studioHost,\n}: {\n flags: DeployAppOptions['flags']\n isExternal: boolean\n output: Output\n studioHost: string | undefined\n}): string | undefined {\n const url = flags.url\n if (!url) {\n return studioHost\n }\n\n if (isExternal) {\n const normalized = normalizeUrl(url)\n const validation = validateUrl(normalized)\n if (validation !== true) {\n output.error(validation, {exit: exitCodes.USAGE_ERROR})\n return undefined\n }\n return normalized\n }\n\n // For internal deploys, strip protocol prefix and .sanity.studio suffix if present\n const hostname = url.replace(/^https?:\\/\\//i, '').replace(/\\.sanity\\.studio\\/?$/i, '')\n\n // If the result still looks like a URL (contains dots), the user likely meant --external\n if (hostname.includes('.')) {\n output.error(\n `\"${hostname}\" does not look like a sanity.studio hostname. Did you mean to use --external?`,\n {exit: exitCodes.USAGE_ERROR},\n )\n return undefined\n }\n\n // Validate hostname characters (alphanumeric and hyphens only)\n if (!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/i.test(hostname)) {\n output.error(\n `Invalid studio hostname \"${hostname}\". Hostnames can only contain letters, numbers, and hyphens.`,\n {exit: exitCodes.USAGE_ERROR},\n )\n return undefined\n }\n\n return hostname\n}\n"],"names":["basename","dirname","styleText","createGzip","CLIError","exitCodes","getLocalPackageVersion","spinner","pack","createDeployment","getAppId","NO_PROJECT_ID","buildStudio","shouldAutoUpdate","formatSchemaValidation","SchemaExtractionError","checkDir","createStudioUserApplication","deployDebug","deployStudioSchemasAndManifests","findUserApplicationForStudio","normalizeUrl","validateUrl","deployStudio","options","cliConfig","flags","output","projectRoot","sourceDir","workDir","directory","configPath","path","appId","projectId","api","installedSanityVersion","isAutoUpdating","isExternal","external","urlType","appHost","resolveAppHost","studioHost","error","exit","spin","userApplication","unattended","yes","flagHint","USAGE_ERROR","log","shouldBuild","build","autoUpdatesEnabled","calledFromDeploy","outDir","studioManifest","outPath","schemaRequired","verbose","validation","tarball","start","succeed","err","fail","parentDir","base","entries","pipe","location","applicationId","id","isApp","manifest","version","example","message","oclif","RUNTIME_ERROR","url","normalized","undefined","hostname","replace","includes","test"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAC3C,SAAQC,SAAS,QAAO,YAAW;AACnC,SAAQC,UAAU,QAAkB,YAAW;AAE/C,SAAQC,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,SAAS,EAAEC,sBAAsB,QAAoB,mBAAkB;AAC/E,SAAQC,OAAO,QAAO,sBAAqB;AAE3C,SAAQC,IAAI,QAAO,SAAQ;AAE3B,SAAQC,gBAAgB,QAAO,qCAAoC;AACnE,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,aAAa,QAAO,8BAA6B;AACzD,SAAQC,WAAW,QAAO,0BAAyB;AACnD,SAAQC,gBAAgB,QAAO,+BAA8B;AAC7D,SAAQC,sBAAsB,QAAO,sCAAqC;AAC1E,SAAQC,qBAAqB,QAAO,2CAA0C;AAC9E,SAAQC,QAAQ,QAAO,gBAAe;AACtC,SAAQC,2BAA2B,QAAO,mCAAkC;AAC5E,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAAQC,+BAA+B,QAAO,uCAAsC;AACpF,SAAQC,4BAA4B,QAAO,oCAAmC;AAE9E,SAAQC,YAAY,EAAEC,WAAW,QAAO,gBAAe;AAEvD,OAAO,eAAeC,aAAaC,OAAyB;IAC1D,MAAM,EAACC,SAAS,EAAEC,KAAK,EAAEC,MAAM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KqB,IAAI;QACTlD,YAAY,0BAA0B2B;QACtClB,OAAOkB,KAAK,CAAC,CAAC,wBAAwB,EAAEA,OAAO,EAAE;YAACC,MAAM;QAAC;IAC3D;AACF;AAEA,SAASH,eAAe,EACtBjB,KAAK,EACLa,UAAU,EACVZ,MAAM,EACNiB,UAAU,EAMX;IACC,MAAMuC,MAAMzD,MAAMyD,GAAG;IACrB,IAAI,CAACA,KAAK;QACR,OAAOvC;IACT;IAEA,IAAIL,YAAY;QACd,MAAM6C,aAAa/D,aAAa8D;QAChC,MAAMpB,aAAazC,YAAY8D;QAC/B,IAAIrB,eAAe,MAAM;YACvBpC,OAAOkB,KAAK,CAACkB,YAAY;gBAACjB,MAAMzC,UAAU+C,WAAW;YAAA;YACrD,OAAOiC;QACT;QACA,OAAOD;IACT;IAEA,mFAAmF;IACnF,MAAME,WAAWH,IAAII,OAAO,CAAC,iBAAiB,IAAIA,OAAO,CAAC,yBAAyB;IAEnF,yFAAyF;IACzF,IAAID,SAASE,QAAQ,CAAC,MAAM;QAC1B7D,OAAOkB,KAAK,CACV,CAAC,CAAC,EAAEyC,SAAS,8EAA8E,CAAC,EAC5F;YAACxC,MAAMzC,UAAU+C,WAAW;QAAA;QAE9B,OAAOiC;IACT;IAEA,+DAA+D;IAC/D,IAAI,CAAC,mCAAmCI,IAAI,CAACH,WAAW;QACtD3D,OAAOkB,KAAK,CACV,CAAC,yBAAyB,EAAEyC,SAAS,4DAA4D,CAAC,EAClG;YAACxC,MAAMzC,UAAU+C,WAAW;QAAA;QAE9B,OAAOiC;IACT;IAEA,OAAOC;AACT"}
@@ -1,5 +1,5 @@
1
1
  import { styleText } from 'node:util';
2
- import { isInteractive } from '@sanity/cli-core';
2
+ import { getLocalPackageVersion, isInteractive } from '@sanity/cli-core';
3
3
  import { confirm, logSymbols, spinner } from '@sanity/cli-core/ux';
4
4
  import { parse as semverParse } from 'semver';
5
5
  import { startDevServer } from '../../server/devServer.js';
@@ -7,7 +7,6 @@ import { gracefulServerDeath } from '../../server/gracefulServerDeath.js';
7
7
  import { getProjectById } from '../../services/projects.js';
8
8
  import { getAppId } from '../../util/appId.js';
9
9
  import { compareDependencyVersions } from '../../util/compareDependencyVersions.js';
10
- import { getLocalPackageVersion } from '../../util/getLocalPackageVersion.js';
11
10
  import { getPackageManagerChoice } from '../../util/packageManager/packageManagerChoice.js';
12
11
  import { upgradePackages } from '../../util/packageManager/upgradePackages.js';
13
12
  import { checkRequiredDependencies } from '../build/checkRequiredDependencies.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/dev/startStudioDevServer.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {isInteractive} from '@sanity/cli-core'\nimport {confirm, logSymbols, spinner} from '@sanity/cli-core/ux'\nimport {parse as semverParse} from 'semver'\n\nimport {startDevServer} from '../../server/devServer.js'\nimport {gracefulServerDeath} from '../../server/gracefulServerDeath.js'\nimport {getProjectById} from '../../services/projects.js'\nimport {getAppId} from '../../util/appId.js'\nimport {compareDependencyVersions} from '../../util/compareDependencyVersions.js'\nimport {getLocalPackageVersion} from '../../util/getLocalPackageVersion.js'\nimport {getPackageManagerChoice} from '../../util/packageManager/packageManagerChoice.js'\nimport {upgradePackages} from '../../util/packageManager/upgradePackages.js'\nimport {checkRequiredDependencies} from '../build/checkRequiredDependencies.js'\nimport {checkStudioDependencyVersions} from '../build/checkStudioDependencyVersions.js'\nimport {shouldAutoUpdate} from '../build/shouldAutoUpdate.js'\nimport {devDebug} from './devDebug.js'\nimport {getDashboardAppURL} from './getDashboardAppUrl.js'\nimport {getDevServerConfig} from './getDevServerConfig.js'\nimport {type DevActionOptions} from './types.js'\n\nexport async function startStudioDevServer(\n options: DevActionOptions,\n): Promise<{close?: () => Promise<void>}> {\n const {cliConfig, flags, output, workDir} = options\n const projectId = cliConfig?.api?.projectId\n let organizationId: string | undefined\n\n const loadInDashboard = flags['load-in-dashboard']\n\n // Check studio dependency versions\n await checkStudioDependencyVersions(workDir, output)\n\n const {installedSanityVersion} = await checkRequiredDependencies(options)\n\n // Check if auto-updates are enabled\n const autoUpdatesEnabled = shouldAutoUpdate({cliConfig, flags, output})\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSanityVersion = semverParse(installedSanityVersion)?.version\n if (!cleanSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n\n const sanityDependencies = [\n {name: 'sanity', version: cleanSanityVersion},\n {name: '@sanity/vision', version: cleanSanityVersion},\n ]\n\n output.log(`${logSymbols.info} Running with auto-updates enabled`)\n\n // Check local versions against deployed versions\n let result: Awaited<ReturnType<typeof compareDependencyVersions>> | undefined\n\n const appId = getAppId(cliConfig)\n\n try {\n result = await compareDependencyVersions(sanityDependencies, workDir, {appId})\n } catch (err) {\n output.warn(`Failed to compare local versions against auto-updating versions: ${err}`)\n }\n\n if (result?.unresolvedPrerelease.length) {\n for (const mod of result.unresolvedPrerelease) {\n output.warn(\n `Your local version of ${mod.pkg} (${mod.version}) is a prerelease not available on the auto-updates CDN. The locally installed version will be used.`,\n )\n }\n }\n\n // mismatch between local and auto-updating dependencies\n if (result?.mismatched.length) {\n const message =\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 run with the same versions locally as will be used when deploying.\\n\\n` +\n `${result.mismatched.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')}\\n\\n`\n\n if (isInteractive()) {\n const shouldUpgrade = await confirm({\n default: true,\n message: styleText('yellow', `${message}Do you want to upgrade local versions?`),\n })\n if (shouldUpgrade) {\n await upgradePackages(\n {\n packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,\n packages: result.mismatched.map((res) => [res.pkg, res.remote]),\n },\n {output, workDir},\n )\n }\n } else {\n // In this case we warn the user but we don't ask them if they want to upgrade because it's not interactive.\n output.log(styleText('yellow', message))\n }\n }\n }\n\n if (cliConfig?.schemaExtraction?.enabled) {\n output.log(`${logSymbols.info} Running dev server with schema extraction enabled`)\n }\n\n const config = getDevServerConfig({cliConfig, flags, output, workDir})\n\n if (loadInDashboard) {\n if (!projectId) {\n output.error('Project Id is required to load in dashboard', {exit: 1})\n }\n\n try {\n const project = await getProjectById(projectId!)\n organizationId = project.organizationId!\n } catch (error) {\n devDebug('Error getting organization id from project id', error)\n output.error('Failed to get organization id from project id', {exit: 1})\n }\n }\n\n try {\n const startTime = Date.now()\n const spin = spinner('Starting dev server').start()\n const {close, server} = await startDevServer(config)\n\n const {info: loggerInfo} = server.config.logger\n const {port} = server.config.server\n const httpHost = config.httpHost || 'localhost'\n\n if (loadInDashboard) {\n spin.succeed()\n\n output.log(`Dev server started on port ${port}`)\n output.log(`View your studio in the Sanity dashboard here:`)\n output.log(\n styleText(\n ['blue', 'underline'],\n await getDashboardAppURL({\n httpHost,\n httpPort: port,\n organizationId: organizationId!,\n }),\n ),\n )\n } else {\n const startupDuration = Date.now() - startTime\n const url = `http://${httpHost || 'localhost'}:${port}${config.basePath}`\n const appType = 'Sanity Studio'\n\n const viteVersion = await getLocalPackageVersion('vite', import.meta.url)\n spin.succeed()\n\n loggerInfo(\n `${appType} ` +\n `using ${styleText('cyan', `vite@${viteVersion}`)} ` +\n `ready in ${styleText('cyan', `${Math.ceil(startupDuration)}ms`)} ` +\n `and running at ${styleText('cyan', url)}`,\n )\n }\n\n return {close}\n } catch (err) {\n devDebug('Error starting studio dev server', err)\n throw gracefulServerDeath('dev', config.httpHost, config.httpPort, err)\n }\n}\n"],"names":["styleText","isInteractive","confirm","logSymbols","spinner","parse","semverParse","startDevServer","gracefulServerDeath","getProjectById","getAppId","compareDependencyVersions","getLocalPackageVersion","getPackageManagerChoice","upgradePackages","checkRequiredDependencies","checkStudioDependencyVersions","shouldAutoUpdate","devDebug","getDashboardAppURL","getDevServerConfig","startStudioDevServer","options","cliConfig","flags","output","workDir","projectId","api","organizationId","loadInDashboard","installedSanityVersion","autoUpdatesEnabled","cleanSanityVersion","version","Error","sanityDependencies","name","log","info","result","appId","err","warn","unresolvedPrerelease","length","mod","pkg","mismatched","message","map","installed","remote","join","shouldUpgrade","default","packageManager","interactive","chosen","packages","res","schemaExtraction","enabled","config","error","exit","project","startTime","Date","now","spin","start","close","server","loggerInfo","logger","port","httpHost","succeed","httpPort","startupDuration","url","basePath","appType","viteVersion","Math","ceil"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,aAAa,QAAO,mBAAkB;AAC9C,SAAQC,OAAO,EAAEC,UAAU,EAAEC,OAAO,QAAO,sBAAqB;AAChE,SAAQC,SAASC,WAAW,QAAO,SAAQ;AAE3C,SAAQC,cAAc,QAAO,4BAA2B;AACxD,SAAQC,mBAAmB,QAAO,sCAAqC;AACvE,SAAQC,cAAc,QAAO,6BAA4B;AACzD,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,yBAAyB,QAAO,0CAAyC;AACjF,SAAQC,sBAAsB,QAAO,uCAAsC;AAC3E,SAAQC,uBAAuB,QAAO,oDAAmD;AACzF,SAAQC,eAAe,QAAO,+CAA8C;AAC5E,SAAQC,yBAAyB,QAAO,wCAAuC;AAC/E,SAAQC,6BAA6B,QAAO,4CAA2C;AACvF,SAAQC,gBAAgB,QAAO,+BAA8B;AAC7D,SAAQC,QAAQ,QAAO,gBAAe;AACtC,SAAQC,kBAAkB,QAAO,0BAAyB;AAC1D,SAAQC,kBAAkB,QAAO,0BAAyB;AAG1D,OAAO,eAAeC,qBACpBC,OAAyB;IAEzB,MAAM,EAACC,SAAS,EAAEC,KAAK,EAAEC,MAAM,EAAEC,OAAO,EAAC,GAAGJ;IAC5C,MAAMK,YAAYJ,WAAWK,KAAKD;IAClC,IAAIE;IAEJ,MAAMC,kBAAkBN,KAAK,CAAC,oBAAoB;IAElD,mCAAmC;IACnC,MAAMR,8BAA8BU,SAASD;IAE7C,MAAM,EAACM,sBAAsB,EAAC,GAAG,MAAMhB,0BAA0BO;IAEjE,oCA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AM,CAACU,MAAM;QACnC,MAAMI,WAAWd,OAAOc,QAAQ,IAAI;QAEpC,IAAI/C,iBAAiB;YACnBwC,KAAKQ,OAAO;YAEZrD,OAAOa,GAAG,CAAC,CAAC,2BAA2B,EAAEsC,MAAM;YAC/CnD,OAAOa,GAAG,CAAC,CAAC,8CAA8C,CAAC;YAC3Db,OAAOa,GAAG,CACRtC,UACE;gBAAC;gBAAQ;aAAY,EACrB,MAAMmB,mBAAmB;gBACvB0D;gBACAE,UAAUH;gBACV/C,gBAAgBA;YAClB;QAGN,OAAO;YACL,MAAMmD,kBAAkBZ,KAAKC,GAAG,KAAKF;YACrC,MAAMc,MAAM,CAAC,OAAO,EAAEJ,YAAY,YAAY,CAAC,EAAED,OAAOb,OAAOmB,QAAQ,EAAE;YACzE,MAAMC,UAAU;YAEhB,MAAMC,cAAc,MAAMxE,uBAAuB,QAAQ,YAAYqE,GAAG;YACxEX,KAAKQ,OAAO;YAEZJ,WACE,GAAGS,QAAQ,CAAC,CAAC,GACX,CAAC,MAAM,EAAEnF,UAAU,QAAQ,CAAC,KAAK,EAAEoF,aAAa,EAAE,CAAC,CAAC,GACpD,CAAC,SAAS,EAAEpF,UAAU,QAAQ,GAAGqF,KAAKC,IAAI,CAACN,iBAAiB,EAAE,CAAC,EAAE,CAAC,CAAC,GACnE,CAAC,eAAe,EAAEhF,UAAU,QAAQiF,MAAM;QAEhD;QAEA,OAAO;YAACT;QAAK;IACf,EAAE,OAAO9B,KAAK;QACZxB,SAAS,oCAAoCwB;QAC7C,MAAMlC,oBAAoB,OAAOuD,OAAOc,QAAQ,EAAEd,OAAOgB,QAAQ,EAAErC;IACrE;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/dev/startStudioDevServer.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {getLocalPackageVersion, isInteractive} from '@sanity/cli-core'\nimport {confirm, logSymbols, spinner} from '@sanity/cli-core/ux'\nimport {parse as semverParse} from 'semver'\n\nimport {startDevServer} from '../../server/devServer.js'\nimport {gracefulServerDeath} from '../../server/gracefulServerDeath.js'\nimport {getProjectById} from '../../services/projects.js'\nimport {getAppId} from '../../util/appId.js'\nimport {compareDependencyVersions} from '../../util/compareDependencyVersions.js'\nimport {getPackageManagerChoice} from '../../util/packageManager/packageManagerChoice.js'\nimport {upgradePackages} from '../../util/packageManager/upgradePackages.js'\nimport {checkRequiredDependencies} from '../build/checkRequiredDependencies.js'\nimport {checkStudioDependencyVersions} from '../build/checkStudioDependencyVersions.js'\nimport {shouldAutoUpdate} from '../build/shouldAutoUpdate.js'\nimport {devDebug} from './devDebug.js'\nimport {getDashboardAppURL} from './getDashboardAppUrl.js'\nimport {getDevServerConfig} from './getDevServerConfig.js'\nimport {type DevActionOptions} from './types.js'\n\nexport async function startStudioDevServer(\n options: DevActionOptions,\n): Promise<{close?: () => Promise<void>}> {\n const {cliConfig, flags, output, workDir} = options\n const projectId = cliConfig?.api?.projectId\n let organizationId: string | undefined\n\n const loadInDashboard = flags['load-in-dashboard']\n\n // Check studio dependency versions\n await checkStudioDependencyVersions(workDir, output)\n\n const {installedSanityVersion} = await checkRequiredDependencies(options)\n\n // Check if auto-updates are enabled\n const autoUpdatesEnabled = shouldAutoUpdate({cliConfig, flags, output})\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSanityVersion = semverParse(installedSanityVersion)?.version\n if (!cleanSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n\n const sanityDependencies = [\n {name: 'sanity', version: cleanSanityVersion},\n {name: '@sanity/vision', version: cleanSanityVersion},\n ]\n\n output.log(`${logSymbols.info} Running with auto-updates enabled`)\n\n // Check local versions against deployed versions\n let result: Awaited<ReturnType<typeof compareDependencyVersions>> | undefined\n\n const appId = getAppId(cliConfig)\n\n try {\n result = await compareDependencyVersions(sanityDependencies, workDir, {appId})\n } catch (err) {\n output.warn(`Failed to compare local versions against auto-updating versions: ${err}`)\n }\n\n if (result?.unresolvedPrerelease.length) {\n for (const mod of result.unresolvedPrerelease) {\n output.warn(\n `Your local version of ${mod.pkg} (${mod.version}) is a prerelease not available on the auto-updates CDN. The locally installed version will be used.`,\n )\n }\n }\n\n // mismatch between local and auto-updating dependencies\n if (result?.mismatched.length) {\n const message =\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 run with the same versions locally as will be used when deploying.\\n\\n` +\n `${result.mismatched.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')}\\n\\n`\n\n if (isInteractive()) {\n const shouldUpgrade = await confirm({\n default: true,\n message: styleText('yellow', `${message}Do you want to upgrade local versions?`),\n })\n if (shouldUpgrade) {\n await upgradePackages(\n {\n packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,\n packages: result.mismatched.map((res) => [res.pkg, res.remote]),\n },\n {output, workDir},\n )\n }\n } else {\n // In this case we warn the user but we don't ask them if they want to upgrade because it's not interactive.\n output.log(styleText('yellow', message))\n }\n }\n }\n\n if (cliConfig?.schemaExtraction?.enabled) {\n output.log(`${logSymbols.info} Running dev server with schema extraction enabled`)\n }\n\n const config = getDevServerConfig({cliConfig, flags, output, workDir})\n\n if (loadInDashboard) {\n if (!projectId) {\n output.error('Project Id is required to load in dashboard', {exit: 1})\n }\n\n try {\n const project = await getProjectById(projectId!)\n organizationId = project.organizationId!\n } catch (error) {\n devDebug('Error getting organization id from project id', error)\n output.error('Failed to get organization id from project id', {exit: 1})\n }\n }\n\n try {\n const startTime = Date.now()\n const spin = spinner('Starting dev server').start()\n const {close, server} = await startDevServer(config)\n\n const {info: loggerInfo} = server.config.logger\n const {port} = server.config.server\n const httpHost = config.httpHost || 'localhost'\n\n if (loadInDashboard) {\n spin.succeed()\n\n output.log(`Dev server started on port ${port}`)\n output.log(`View your studio in the Sanity dashboard here:`)\n output.log(\n styleText(\n ['blue', 'underline'],\n await getDashboardAppURL({\n httpHost,\n httpPort: port,\n organizationId: organizationId!,\n }),\n ),\n )\n } else {\n const startupDuration = Date.now() - startTime\n const url = `http://${httpHost || 'localhost'}:${port}${config.basePath}`\n const appType = 'Sanity Studio'\n\n const viteVersion = await getLocalPackageVersion('vite', import.meta.url)\n spin.succeed()\n\n loggerInfo(\n `${appType} ` +\n `using ${styleText('cyan', `vite@${viteVersion}`)} ` +\n `ready in ${styleText('cyan', `${Math.ceil(startupDuration)}ms`)} ` +\n `and running at ${styleText('cyan', url)}`,\n )\n }\n\n return {close}\n } catch (err) {\n devDebug('Error starting studio dev server', err)\n throw gracefulServerDeath('dev', config.httpHost, config.httpPort, err)\n }\n}\n"],"names":["styleText","getLocalPackageVersion","isInteractive","confirm","logSymbols","spinner","parse","semverParse","startDevServer","gracefulServerDeath","getProjectById","getAppId","compareDependencyVersions","getPackageManagerChoice","upgradePackages","checkRequiredDependencies","checkStudioDependencyVersions","shouldAutoUpdate","devDebug","getDashboardAppURL","getDevServerConfig","startStudioDevServer","options","cliConfig","flags","output","workDir","projectId","api","organizationId","loadInDashboard","installedSanityVersion","autoUpdatesEnabled","cleanSanityVersion","version","Error","sanityDependencies","name","log","info","result","appId","err","warn","unresolvedPrerelease","length","mod","pkg","mismatched","message","map","installed","remote","join","shouldUpgrade","default","packageManager","interactive","chosen","packages","res","schemaExtraction","enabled","config","error","exit","project","startTime","Date","now","spin","start","close","server","loggerInfo","logger","port","httpHost","succeed","httpPort","startupDuration","url","basePath","appType","viteVersion","Math","ceil"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,sBAAsB,EAAEC,aAAa,QAAO,mBAAkB;AACtE,SAAQC,OAAO,EAAEC,UAAU,EAAEC,OAAO,QAAO,sBAAqB;AAChE,SAAQC,SAASC,WAAW,QAAO,SAAQ;AAE3C,SAAQC,cAAc,QAAO,4BAA2B;AACxD,SAAQC,mBAAmB,QAAO,sCAAqC;AACvE,SAAQC,cAAc,QAAO,6BAA4B;AACzD,SAAQC,QAAQ,QAAO,s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Q,OAAO;YAEZJ,WACE,GAAGS,QAAQ,CAAC,CAAC,GACX,CAAC,MAAM,EAAEnF,UAAU,QAAQ,CAAC,KAAK,EAAEoF,aAAa,EAAE,CAAC,CAAC,GACpD,CAAC,SAAS,EAAEpF,UAAU,QAAQ,GAAGqF,KAAKC,IAAI,CAACN,iBAAiB,EAAE,CAAC,EAAE,CAAC,CAAC,GACnE,CAAC,eAAe,EAAEhF,UAAU,QAAQiF,MAAM;QAEhD;QAEA,OAAO;YAACT;QAAK;IACf,EAAE,OAAO9B,KAAK;QACZxB,SAAS,oCAAoCwB;QAC7C,MAAMjC,oBAAoB,OAAOsD,OAAOc,QAAQ,EAAEd,OAAOgB,QAAQ,EAAErC;IACrE;AACF"}
@@ -3,6 +3,7 @@ import { relative, resolve } from 'node:path';
3
3
  import { getCliConfig } from '@sanity/cli-core';
4
4
  import { spinner } from '@sanity/cli-core/ux';
5
5
  import { getErrorMessage } from '../../util/getErrorMessage.js';
6
+ import { coreAppManifestSchema } from './types.js';
6
7
  /**
7
8
  * Resolves app.icon from config (a file path) to an SVG string for the manifest.
8
9
  * The manifest expects the SVG string inline, not a path.
@@ -49,7 +50,7 @@ import { getErrorMessage } from '../../util/getErrorMessage.js';
49
50
  spin.succeed('Manifest creation skipped: no icon or title found in app configuration');
50
51
  return undefined;
51
52
  }
52
- const manifest = {
53
+ const manifest = coreAppManifestSchema.parse({
53
54
  version: '1',
54
55
  ...icon ? {
55
56
  icon
@@ -57,7 +58,7 @@ import { getErrorMessage } from '../../util/getErrorMessage.js';
57
58
  ...app.title ? {
58
59
  title: app.title
59
60
  } : {}
60
- };
61
+ });
61
62
  spin.succeed(`Extracted manifest`);
62
63
  return manifest;
63
64
  } catch (err) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/manifest/extractAppManifest.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\nimport {relative, resolve} from 'node:path'\n\nimport {getCliConfig} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\n\nimport {getErrorMessage} from '../../util/getErrorMessage.js'\nimport {type AppManifest} from './types.js'\n\ninterface ExtractAppManifestOptions {\n workDir: string\n}\n\n/**\n * Resolves app.icon from config (a file path) to an SVG string for the manifest.\n * The manifest expects the SVG string inline, not a path.\n * Brett sanitizes SVGs so it's skipped here.\n */\nasync function readIconFromPath(workDir: string, iconPath: string): Promise<string> {\n const resolvedPath = resolve(workDir, iconPath)\n const pathRelativeToWorkDir = relative(workDir, resolvedPath)\n if (pathRelativeToWorkDir.startsWith('..')) {\n throw new Error(\n `Icon path \"${iconPath}\" resolves outside the project directory and is not allowed.`,\n )\n }\n\n let content: string\n try {\n content = await readFile(resolvedPath, 'utf8')\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n throw new Error(\n `Could not read icon file at \"${iconPath}\" (resolved: ${resolvedPath}): ${message}`,\n {cause: err},\n )\n }\n\n const trimmed = content.trim()\n if (!/<svg[\\s>]/i.test(trimmed)) {\n throw new Error(\n `Icon file at \"${iconPath}\" does not contain an SVG element. App manifest icons must be SVG files.`,\n )\n }\n\n return trimmed\n}\n\n/**\n *\n * This functions slightly differently from the studio manifest extraction function.\n * We don't need to parse very complicated information like schemas and tools.\n * The app icon in config is a file path (e.g. relative to project root); its content is read and inlined in the manifest.\n */\nexport async function extractAppManifest(\n options: ExtractAppManifestOptions,\n): Promise<AppManifest | undefined> {\n const {workDir} = options\n const {app} = await getCliConfig(workDir)\n if (!app) {\n return undefined\n }\n\n const spin = spinner('Extracting manifest').start()\n\n try {\n let icon: string | undefined\n if (app.icon) {\n icon = await readIconFromPath(workDir, app.icon)\n }\n\n if (!icon && !app.title) {\n spin.succeed('Manifest creation skipped: no icon or title found in app configuration')\n return undefined\n }\n\n const manifest: AppManifest = {\n version: '1',\n ...(icon ? {icon} : {}),\n ...(app.title ? {title: app.title} : {}),\n }\n\n spin.succeed(`Extracted manifest`)\n\n return manifest\n } catch (err) {\n const message = getErrorMessage(err)\n spin.fail(message)\n throw err\n }\n}\n"],"names":["readFile","relative","resolve","getCliConfig","spinner","getErrorMessage","readIconFromPath","workDir","iconPath","resolvedPath","pathRelativeToWorkDir","startsWith","Error","content","err","message","String","cause","trimmed","trim","test","extractAppManifest","options","app","undefined","spin","start","icon","title","succeed","manifest","version","fail"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AACzC,SAAQC,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAE3C,SAAQC,YAAY,QAAO,mBAAkB;AAC7C,SAAQC,OAAO,QAAO,sBAAqB;AAE3C,SAAQC,eAAe,QAAO,gCAA+B;AAO7D;;;;CAIC,GACD,eAAeC,iBAAiBC,OAAe,EAAEC,QAAgB;IAC/D,MAAMC,eAAeP,QAAQK,SAASC;IACtC,MAAME,wBAAwBT,SAASM,SAASE;IAChD,IAAIC,sBAAsBC,UAAU,CAAC,OAAO;QAC1C,MAAM,IAAIC,MACR,CAAC,WAAW,EAAEJ,SAAS,4DAA4D,CAAC;IAExF;IAEA,IAAIK;IACJ,IAAI;QACFA,UAAU,MAAMb,SAASS,cAAc;IACzC,EAAE,OAAOK,KAAK;QACZ,MAAMC,UAAUD,eAAeF,QAAQE,IAAIC,OAAO,GAAGC,OAAOF;QAC5D,MAAM,IAAIF,MACR,CAAC,6BAA6B,EAAEJ,SAAS,aAAa,EAAEC,aAAa,GAAG,EAAEM,SAAS,EACnF;YAACE,OAAOH;QAAG;IAEf;IAEA,MAAMI,UAAUL,QAAQM,IAAI;IAC5B,IAAI,CAAC,aAAaC,IAAI,CAACF,UAAU;QAC/B,MAAM,IAAIN,MACR,CAAC,cAAc,EAAEJ,SAAS,wEAAwE,CAAC;IAEvG;IAEA,OAAOU;AACT;AAEA;;;;;CAKC,GACD,OAAO,eAAeG,mBACpBC,OAAkC;IAElC,MAAM,EAACf,OAAO,EAAC,GAAGe;IAClB,MAAM,EAACC,GAAG,EAAC,GAAG,MAAMpB,aAAaI;IACjC,IAAI,CAACgB,KAAK;QACR,OAAOC;IACT;IAEA,MAAMC,OAAOrB,QAAQ,uBAAuBsB,KAAK;IAEjD,IAAI;QACF,IAAIC;QACJ,IAAIJ,IAAII,IAAI,EAAE;YACZA,OAAO,MAAMrB,iBAAiBC,SAASgB,IAAII,IAAI;QACjD;QAEA,IAAI,CAACA,QAAQ,CAACJ,IAAIK,KAAK,EAAE;YACvBH,KAAKI,OAAO,CAAC;YACb,OAAOL;QACT;QAEA,MAAMM,WAAwB;YAC5BC,SAAS;YACT,GAAIJ,OAAO;gBAACA;YAAI,IAAI,CAAC,CAAC;YACtB,GAAIJ,IAAIK,KAAK,GAAG;gBAACA,OAAOL,IAAIK,KAAK;YAAA,IAAI,CAAC,CAAC;QACzC;QAEAH,KAAKI,OAAO,CAAC,CAAC,kBAAkB,CAAC;QAEjC,OAAOC;IACT,EAAE,OAAOhB,KAAK;QACZ,MAAMC,UAAUV,gBAAgBS;QAChCW,KAAKO,IAAI,CAACjB;QACV,MAAMD;IACR;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/manifest/extractAppManifest.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\nimport {relative, resolve} from 'node:path'\n\nimport {getCliConfig} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\n\nimport {getErrorMessage} from '../../util/getErrorMessage.js'\nimport {type CoreAppManifest, coreAppManifestSchema} from './types.js'\n\ninterface ExtractAppManifestOptions {\n workDir: string\n}\n\n/**\n * Resolves app.icon from config (a file path) to an SVG string for the manifest.\n * The manifest expects the SVG string inline, not a path.\n * Brett sanitizes SVGs so it's skipped here.\n */\nasync function readIconFromPath(workDir: string, iconPath: string): Promise<string> {\n const resolvedPath = resolve(workDir, iconPath)\n const pathRelativeToWorkDir = relative(workDir, resolvedPath)\n if (pathRelativeToWorkDir.startsWith('..')) {\n throw new Error(\n `Icon path \"${iconPath}\" resolves outside the project directory and is not allowed.`,\n )\n }\n\n let content: string\n try {\n content = await readFile(resolvedPath, 'utf8')\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n throw new Error(\n `Could not read icon file at \"${iconPath}\" (resolved: ${resolvedPath}): ${message}`,\n {cause: err},\n )\n }\n\n const trimmed = content.trim()\n if (!/<svg[\\s>]/i.test(trimmed)) {\n throw new Error(\n `Icon file at \"${iconPath}\" does not contain an SVG element. App manifest icons must be SVG files.`,\n )\n }\n\n return trimmed\n}\n\n/**\n *\n * This functions slightly differently from the studio manifest extraction function.\n * We don't need to parse very complicated information like schemas and tools.\n * The app icon in config is a file path (e.g. relative to project root); its content is read and inlined in the manifest.\n */\nexport async function extractAppManifest(\n options: ExtractAppManifestOptions,\n): Promise<CoreAppManifest | undefined> {\n const {workDir} = options\n const {app} = await getCliConfig(workDir)\n if (!app) {\n return undefined\n }\n\n const spin = spinner('Extracting manifest').start()\n\n try {\n let icon: string | undefined\n if (app.icon) {\n icon = await readIconFromPath(workDir, app.icon)\n }\n\n if (!icon && !app.title) {\n spin.succeed('Manifest creation skipped: no icon or title found in app configuration')\n return undefined\n }\n\n const manifest: CoreAppManifest = coreAppManifestSchema.parse({\n version: '1',\n ...(icon ? {icon} : {}),\n ...(app.title ? {title: app.title} : {}),\n })\n\n spin.succeed(`Extracted manifest`)\n\n return manifest\n } catch (err) {\n const message = getErrorMessage(err)\n spin.fail(message)\n throw err\n }\n}\n"],"names":["readFile","relative","resolve","getCliConfig","spinner","getErrorMessage","coreAppManifestSchema","readIconFromPath","workDir","iconPath","resolvedPath","pathRelativeToWorkDir","startsWith","Error","content","err","message","String","cause","trimmed","trim","test","extractAppManifest","options","app","undefined","spin","start","icon","title","succeed","manifest","parse","version","fail"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AACzC,SAAQC,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAE3C,SAAQC,YAAY,QAAO,mBAAkB;AAC7C,SAAQC,OAAO,QAAO,sBAAqB;AAE3C,SAAQC,eAAe,QAAO,gCAA+B;AAC7D,SAA8BC,qBAAqB,QAAO,aAAY;AAMtE;;;;C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,KAAK,GAAG;gBAACA,OAAOL,IAAIK,KAAK;YAAA,IAAI,CAAC,CAAC;QACzC;QAEAH,KAAKI,OAAO,CAAC,CAAC,kBAAkB,CAAC;QAEjC,OAAOC;IACT,EAAE,OAAOhB,KAAK;QACZ,MAAMC,UAAUX,gBAAgBU;QAChCW,KAAKQ,IAAI,CAAClB;QACV,MAAMD;IACR;AACF"}
@@ -1,6 +1,15 @@
1
1
  import { z } from 'zod/mini';
2
2
  export const SANITY_WORKSPACE_SCHEMA_ID_PREFIX = '_.schemas';
3
3
  export const CURRENT_WORKSPACE_SCHEMA_VERSION = '2025-05-01';
4
+ /**
5
+ * Core-app application manifest. Mirrors the workbench's
6
+ * `CoreAppUserApplicationManifest` schema. Strictly validated via zod
7
+ * since the CLI produces the payload in full.
8
+ */ export const coreAppManifestSchema = z.object({
9
+ icon: z.optional(z.string()),
10
+ title: z.optional(z.string()),
11
+ version: z.string()
12
+ });
4
13
  export const extractManifestWorkerData = z.object({
5
14
  configPath: z.string(),
6
15
  workDir: z.string()
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/manifest/types.ts"],"sourcesContent":["import {type SanityDocumentLike} from '@sanity/types'\nimport {type MediaLibraryConfig} from 'sanity'\nimport {z} from 'zod/mini'\n\nexport const SANITY_WORKSPACE_SCHEMA_ID_PREFIX = '_.schemas'\nexport const CURRENT_WORKSPACE_SCHEMA_VERSION = '2025-05-01'\n\nexport type ManifestSerializable =\n | boolean\n | ManifestSerializable[]\n | number\n | string\n | {[k: string]: ManifestSerializable}\n\nexport interface CreateManifest {\n createdAt: string\n studioVersion: string | null\n version: number\n workspaces: ManifestWorkspaceFile[]\n}\n\nexport interface AppManifest {\n version: '1'\n\n icon?: string\n title?: string\n}\n\nexport interface ManifestWorkspaceFile extends Omit<CreateWorkspaceManifest, 'schema' | 'tools'> {\n schema: string // filename\n tools: string // filename\n}\n\nexport interface CreateWorkspaceManifest {\n basePath: string\n dataset: string\n /**\n * returns null in the case of the icon not being able to be stringified\n */\n icon: string | null\n name: string\n projectId: string\n schema: ManifestSchemaType[]\n tools: ManifestTool[]\n\n mediaLibrary?: MediaLibraryConfig\n subtitle?: string\n title?: string\n}\n\nexport interface ManifestSchemaType {\n name: string\n type: string\n\n deprecated?: {\n reason: string\n }\n fields?: ManifestField[]\n fieldsets?: ManifestFieldset[]\n hidden?: 'conditional' | boolean\n lists?: ManifestTitledValue[]\n //portable text\n marks?: {\n annotations?: ManifestArrayMember[]\n decorators?: ManifestTitledValue[]\n }\n of?: ManifestArrayMember[]\n options?: Record<string, ManifestSerializable>\n preview?: {\n select: Record<string, string>\n }\n readOnly?: 'conditional' | boolean\n styles?: ManifestTitledValue[]\n title?: string\n to?: ManifestReferenceMember[]\n validation?: ManifestValidationGroup[]\n\n // userland (assignable to ManifestSerializable | undefined)\n // not included to add some typesafty to extractManifest\n // [index: string]: unknown\n}\n\nexport interface ManifestFieldset {\n [index: string]: ManifestSerializable | undefined\n name: string\n\n title?: string\n}\n\nexport interface ManifestTitledValue {\n value: string\n\n title?: string\n}\n\ntype ManifestArrayMember = Omit<ManifestSchemaType, 'name'> & {name?: string}\ntype ManifestReferenceMember = Omit<ManifestSchemaType, 'name'> & {name?: string}\nexport type ManifestField = ManifestSchemaType & {fieldset?: string}\n\nexport interface ManifestValidationGroup {\n rules: ManifestValidationRule[]\n\n level?: 'error' | 'info' | 'warning'\n message?: string\n}\n\nexport type ManifestValidationRule = {\n [index: string]: ManifestSerializable | undefined\n constraint?: ManifestSerializable\n flag: string\n}\n\nexport interface ManifestTool {\n /**\n * returns null in the case of the icon not being able to be stringified\n */\n icon: string | null\n name: string\n title: string\n type: string | null\n}\n\nexport type DefaultWorkspaceSchemaId = `${typeof SANITY_WORKSPACE_SCHEMA_ID_PREFIX}.${string}`\ntype PrefixedWorkspaceSchemaId = `${DefaultWorkspaceSchemaId}.${string}`\nexport type WorkspaceSchemaId = DefaultWorkspaceSchemaId | PrefixedWorkspaceSchemaId\n\nexport interface StoredWorkspaceSchema extends SanityDocumentLike {\n _id: WorkspaceSchemaId\n _type: 'system.schema'\n /**\n * The API expects JSON coming in, but will store a string to save on attribute paths.\n * Consumers must use JSON.parse on the value, but we deploy to the API using ManifestSchemaType[]\n */\n schema: ManifestSchemaType[] | string\n /* api-like version string: date at which the format had a meaningful change */\n version: typeof CURRENT_WORKSPACE_SCHEMA_VERSION | undefined\n workspace: {\n name: string\n title?: string\n }\n\n tag?: string\n}\n\nexport const extractManifestWorkerData = z.object({configPath: z.string(), workDir: z.string()})\n\nexport type ExtractManifestWorkerData = z.infer<typeof extractManifestWorkerData>\n"],"names":["z","SANITY_WORKSPACE_SCHEMA_ID_PREFIX","CURRENT_WORKSPACE_SCHEMA_VERSION","extractManifestWorkerData","object","configPath","string","workDir"],"mappings":"AAEA,SAAQA,CAAC,QAAO,WAAU;AAE1B,OAAO,MAAMC,oCAAoC,YAAW;AAC5D,OAAO,MAAMC,mCAAmC,aAAY;AA2I5D,OAAO,MAAMC,4BAA4BH,EAAEI,MAAM,CAAC;IAACC,YAAYL,EAAEM,MAAM;IAAIC,SAASP,EAAEM,MAAM;AAAE,GAAE"}
1
+ {"version":3,"sources":["../../../src/actions/manifest/types.ts"],"sourcesContent":["import {type SanityDocumentLike} from '@sanity/types'\nimport {type MediaLibraryConfig} from 'sanity'\nimport {z} from 'zod/mini'\n\nexport const SANITY_WORKSPACE_SCHEMA_ID_PREFIX = '_.schemas'\nexport const CURRENT_WORKSPACE_SCHEMA_VERSION = '2025-05-01'\n\nexport type ManifestSerializable =\n | boolean\n | ManifestSerializable[]\n | number\n | string\n | {[k: string]: ManifestSerializable}\n\nexport interface CreateManifest {\n createdAt: string\n studioVersion: string | null\n version: number\n workspaces: ManifestWorkspaceFile[]\n}\n\n/**\n * Core-app application manifest. Mirrors the workbench's\n * `CoreAppUserApplicationManifest` schema. Strictly validated via zod\n * since the CLI produces the payload in full.\n */\nexport const coreAppManifestSchema = z.object({\n icon: z.optional(z.string()),\n title: z.optional(z.string()),\n version: z.string(),\n})\n\nexport type CoreAppManifest = z.infer<typeof coreAppManifestSchema>\n\nexport interface ManifestWorkspaceFile extends Omit<CreateWorkspaceManifest, 'schema' | 'tools'> {\n schema: string // filename\n tools: string // filename\n}\n\nexport interface CreateWorkspaceManifest {\n basePath: string\n dataset: string\n /**\n * returns null in the case of the icon not being able to be stringified\n */\n icon: string | null\n name: string\n projectId: string\n schema: ManifestSchemaType[]\n tools: ManifestTool[]\n\n mediaLibrary?: MediaLibraryConfig\n subtitle?: string\n title?: string\n}\n\nexport interface ManifestSchemaType {\n name: string\n type: string\n\n deprecated?: {\n reason: string\n }\n fields?: ManifestField[]\n fieldsets?: ManifestFieldset[]\n hidden?: 'conditional' | boolean\n lists?: ManifestTitledValue[]\n //portable text\n marks?: {\n annotations?: ManifestArrayMember[]\n decorators?: ManifestTitledValue[]\n }\n of?: ManifestArrayMember[]\n options?: Record<string, ManifestSerializable>\n preview?: {\n select: Record<string, string>\n }\n readOnly?: 'conditional' | boolean\n styles?: ManifestTitledValue[]\n title?: string\n to?: ManifestReferenceMember[]\n validation?: ManifestValidationGroup[]\n\n // userland (assignable to ManifestSerializable | undefined)\n // not included to add some typesafty to extractManifest\n // [index: string]: unknown\n}\n\nexport interface ManifestFieldset {\n [index: string]: ManifestSerializable | undefined\n name: string\n\n title?: string\n}\n\nexport interface ManifestTitledValue {\n value: string\n\n title?: string\n}\n\ntype ManifestArrayMember = Omit<ManifestSchemaType, 'name'> & {name?: string}\ntype ManifestReferenceMember = Omit<ManifestSchemaType, 'name'> & {name?: string}\nexport type ManifestField = ManifestSchemaType & {fieldset?: string}\n\nexport interface ManifestValidationGroup {\n rules: ManifestValidationRule[]\n\n level?: 'error' | 'info' | 'warning'\n message?: string\n}\n\nexport type ManifestValidationRule = {\n [index: string]: ManifestSerializable | undefined\n constraint?: ManifestSerializable\n flag: string\n}\n\nexport interface ManifestTool {\n /**\n * returns null in the case of the icon not being able to be stringified\n */\n icon: string | null\n name: string\n title: string\n type: string | null\n}\n\nexport type DefaultWorkspaceSchemaId = `${typeof SANITY_WORKSPACE_SCHEMA_ID_PREFIX}.${string}`\ntype PrefixedWorkspaceSchemaId = `${DefaultWorkspaceSchemaId}.${string}`\nexport type WorkspaceSchemaId = DefaultWorkspaceSchemaId | PrefixedWorkspaceSchemaId\n\nexport interface StoredWorkspaceSchema extends SanityDocumentLike {\n _id: WorkspaceSchemaId\n _type: 'system.schema'\n /**\n * The API expects JSON coming in, but will store a string to save on attribute paths.\n * Consumers must use JSON.parse on the value, but we deploy to the API using ManifestSchemaType[]\n */\n schema: ManifestSchemaType[] | string\n /* api-like version string: date at which the format had a meaningful change */\n version: typeof CURRENT_WORKSPACE_SCHEMA_VERSION | undefined\n workspace: {\n name: string\n title?: string\n }\n\n tag?: string\n}\n\nexport const extractManifestWorkerData = z.object({configPath: z.string(), workDir: z.string()})\n\nexport type ExtractManifestWorkerData = z.infer<typeof extractManifestWorkerData>\n"],"names":["z","SANITY_WORKSPACE_SCHEMA_ID_PREFIX","CURRENT_WORKSPACE_SCHEMA_VERSION","coreAppManifestSchema","object","icon","optional","string","title","version","extractManifestWorkerData","configPath","workDir"],"mappings":"AAEA,SAAQA,CAAC,QAAO,WAAU;AAE1B,OAAO,MAAMC,oCAAoC,YAAW;AAC5D,OAAO,MAAMC,mCAAmC,aAAY;AAgB5D;;;;CAIC,GACD,OAAO,MAAMC,wBAAwBH,EAAEI,MAAM,CAAC;IAC5CC,MAAML,EAAEM,QAAQ,CAACN,EAAEO,MAAM;IACzBC,OAAOR,EAAEM,QAAQ,CAACN,EAAEO,MAAM;IAC1BE,SAAST,EAAEO,MAAM;AACnB,GAAE;AAwHF,OAAO,MAAMG,4BAA4BV,EAAEI,MAAM,CAAC;IAACO,YAAYX,EAAEO,MAAM;IAAIK,SAASZ,EAAEO,MAAM;AAAE,GAAE"}
@@ -1,7 +1,6 @@
1
1
  import { mkdir, writeFile } from 'node:fs/promises';
2
2
  import { isAbsolute, join, resolve } from 'node:path';
3
- import { subdebug } from '@sanity/cli-core';
4
- import { getLocalPackageVersion } from '../../util/getLocalPackageVersion.js';
3
+ import { getLocalPackageVersion, subdebug } from '@sanity/cli-core';
5
4
  import { writeWorkspaceFiles } from './writeWorkspaceFiles.js';
6
5
  const MANIFEST_FILENAME = 'create-manifest.json';
7
6
  const debug = subdebug('writeManifestFile');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/manifest/writeManifestFile.ts"],"sourcesContent":["import {mkdir, writeFile} from 'node:fs/promises'\nimport {isAbsolute, join, resolve} from 'node:path'\n\nimport {subdebug} from '@sanity/cli-core'\n\nimport {getLocalPackageVersion} from '../../util/getLocalPackageVersion.js'\nimport {type CreateManifest, type CreateWorkspaceManifest} from './types.js'\nimport {writeWorkspaceFiles} from './writeWorkspaceFiles.js'\n\nconst MANIFEST_FILENAME = 'create-manifest.json'\n\nconst debug = subdebug('writeManifestFile')\n\nexport async function writeManifestFile({\n outPath,\n workDir,\n workspaceManifests,\n}: {\n outPath: string\n workDir: string\n workspaceManifests: CreateWorkspaceManifest[]\n}) {\n const staticPath = isAbsolute(outPath) ? outPath : resolve(join(workDir, outPath))\n debug('Writing manifest to %s', staticPath)\n const path = join(staticPath, MANIFEST_FILENAME)\n\n await mkdir(staticPath, {recursive: true})\n\n const workspaceFiles = await writeWorkspaceFiles(workspaceManifests, staticPath)\n\n const manifest: CreateManifest = {\n /**\n * Version history:\n * 1: Initial release.\n * 2: Added tools file.\n * 3. Added studioVersion field.\n */\n createdAt: new Date().toISOString(),\n studioVersion: await getLocalPackageVersion('sanity', workDir),\n version: 3,\n workspaces: workspaceFiles,\n }\n\n await writeFile(path, JSON.stringify(manifest, null, 2))\n}\n"],"names":["mkdir","writeFile","isAbsolute","join","resolve","subdebug","getLocalPackageVersion","writeWorkspaceFiles","MANIFEST_FILENAME","debug","writeManifestFile","outPath","workDir","workspaceManifests","staticPath","path","recursive","workspaceFiles","manifest","createdAt","Date","toISOString","studioVersion","version","workspaces","JSON","stringify"],"mappings":"AAAA,SAAQA,KAAK,EAAEC,SAAS,QAAO,mBAAkB;AACjD,SAAQC,UAAU,EAAEC,IAAI,EAAEC,OAAO,QAAO,YAAW;AAEnD,SAAQC,QAAQ,QAAO,mBAAkB;AAEzC,SAAQC,sBAAsB,QAAO,uCAAsC;AAE3E,SAAQC,mBAAmB,QAAO,2BAA0B;AAE5D,MAAMC,oBAAoB;AAE1B,MAAMC,QAAQJ,SAAS;AAEvB,OAAO,eAAeK,kBAAkB,EACtCC,OAAO,EACPC,OAAO,EACPC,kBAAkB,EAKnB;IACC,MAAMC,aAAaZ,WAAWS,WAAWA,UAAUP,QAAQD,KAAKS,SAASD;IACzEF,MAAM,0BAA0BK;IAChC,MAAMC,OAAOZ,KAAKW,YAAYN;IAE9B,MAAMR,MAAMc,YAAY;QAACE,WAAW;IAAI;IAExC,MAAMC,iBAAiB,MAAMV,oBAAoBM,oBAAoBC;IAErE,MAAMI,WAA2B;QAC/B;;;;;KAKC,GACDC,WAAW,IAAIC,OAAOC,WAAW;QACjCC,eAAe,MAAMhB,uBAAuB,UAAUM;QACtDW,SAAS;QACTC,YAAYP;IACd;IAEA,MAAMhB,UAAUc,MAAMU,KAAKC,SAAS,CAACR,UAAU,MAAM;AACvD"}
1
+ {"version":3,"sources":["../../../src/actions/manifest/writeManifestFile.ts"],"sourcesContent":["import {mkdir, writeFile} from 'node:fs/promises'\nimport {isAbsolute, join, resolve} from 'node:path'\n\nimport {getLocalPackageVersion, subdebug} from '@sanity/cli-core'\n\nimport {type CreateManifest, type CreateWorkspaceManifest} from './types.js'\nimport {writeWorkspaceFiles} from './writeWorkspaceFiles.js'\n\nconst MANIFEST_FILENAME = 'create-manifest.json'\n\nconst debug = subdebug('writeManifestFile')\n\nexport async function writeManifestFile({\n outPath,\n workDir,\n workspaceManifests,\n}: {\n outPath: string\n workDir: string\n workspaceManifests: CreateWorkspaceManifest[]\n}) {\n const staticPath = isAbsolute(outPath) ? outPath : resolve(join(workDir, outPath))\n debug('Writing manifest to %s', staticPath)\n const path = join(staticPath, MANIFEST_FILENAME)\n\n await mkdir(staticPath, {recursive: true})\n\n const workspaceFiles = await writeWorkspaceFiles(workspaceManifests, staticPath)\n\n const manifest: CreateManifest = {\n /**\n * Version history:\n * 1: Initial release.\n * 2: Added tools file.\n * 3. Added studioVersion field.\n */\n createdAt: new Date().toISOString(),\n studioVersion: await getLocalPackageVersion('sanity', workDir),\n version: 3,\n workspaces: workspaceFiles,\n }\n\n await writeFile(path, JSON.stringify(manifest, null, 2))\n}\n"],"names":["mkdir","writeFile","isAbsolute","join","resolve","getLocalPackageVersion","subdebug","writeWorkspaceFiles","MANIFEST_FILENAME","debug","writeManifestFile","outPath","workDir","workspaceManifests","staticPath","path","recursive","workspaceFiles","manifest","createdAt","Date","toISOString","studioVersion","version","workspaces","JSON","stringify"],"mappings":"AAAA,SAAQA,KAAK,EAAEC,SAAS,QAAO,mBAAkB;AACjD,SAAQC,UAAU,EAAEC,IAAI,EAAEC,OAAO,QAAO,YAAW;AAEnD,SAAQC,sBAAsB,EAAEC,QAAQ,QAAO,mBAAkB;AAGjE,SAAQC,mBAAmB,QAAO,2BAA0B;AAE5D,MAAMC,oBAAoB;AAE1B,MAAMC,QAAQH,SAAS;AAEvB,OAAO,eAAeI,kBAAkB,EACtCC,OAAO,EACPC,OAAO,EACPC,kBAAkB,EAKnB;IACC,MAAMC,aAAaZ,WAAWS,WAAWA,UAAUP,QAAQD,KAAKS,SAASD;IACzEF,MAAM,0BAA0BK;IAChC,MAAMC,OAAOZ,KAAKW,YAAYN;IAE9B,MAAMR,MAAMc,YAAY;QAACE,WAAW;IAAI;IAExC,MAAMC,iBAAiB,MAAMV,oBAAoBM,oBAAoBC;IAErE,MAAMI,WAA2B;QAC/B;;;;;KAKC,GACDC,WAAW,IAAIC,OAAOC,WAAW;QACjCC,eAAe,MAAMjB,uBAAuB,UAAUO;QACtDW,SAAS;QACTC,YAAYP;IACd;IAEA,MAAMhB,UAAUc,MAAMU,KAAKC,SAAS,CAACR,UAAU,MAAM;AACvD"}
@@ -1,9 +1,8 @@
1
1
  import { styleText } from 'node:util';
2
2
  import { ux } from '@oclif/core/ux';
3
- import { doImport, getProjectCliClient, resolveLocalPackage, subdebug } from '@sanity/cli-core';
3
+ import { doImport, getLocalPackageVersion, getProjectCliClient, resolveLocalPackage, subdebug } from '@sanity/cli-core';
4
4
  import { spinner } from '@sanity/cli-core/ux';
5
5
  import { SCHEMA_API_VERSION } from '../../services/schemas.js';
6
- import { getLocalPackageVersion } from '../../util/getLocalPackageVersion.js';
7
6
  const iconResolverPath = new URL('../manifest/iconResolver.js', import.meta.url).href;
8
7
  const debug = subdebug('uploadSchemaToLexicon');
9
8
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/schema/uploadSchemaToLexicon.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {ux} from '@oclif/core/ux'\nimport {doImport, getProjectCliClient, resolveLocalPackage, subdebug} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {type StudioManifest, type Workspace} from 'sanity'\n\nimport {SCHEMA_API_VERSION} from '../../services/schemas.js'\nimport {getLocalPackageVersion} from '../../util/getLocalPackageVersion.js'\n\nconst iconResolverPath = new URL('../manifest/iconResolver.js', import.meta.url).href\n\ninterface UploadSchemaToLexiconOptions {\n projectId: string\n workDir: string\n workspaces: Workspace[]\n\n verbose?: boolean\n}\n\nconst debug = subdebug('uploadSchemaToLexicon')\n\n/**\n * Uploads the schemas to Lexicon and returns the studio manifest\n * @param options - The options for the uploadSchemaToLexicon function\n * @returns The studio manifest\n */\nexport async function uploadSchemaToLexicon(\n options: UploadSchemaToLexiconOptions,\n): Promise<StudioManifest | null> {\n const {projectId, verbose, workDir, workspaces} = options\n const spin = spinner('Generating studio manifest').start()\n\n try {\n const schemaDescriptors = new Map<string, string>()\n\n const client = await getProjectCliClient({\n apiVersion: SCHEMA_API_VERSION,\n projectId,\n requestTagPrefix: 'sanity.cli.deploy',\n requireUser: true,\n })\n\n const [bundleVersion, {generateStudioManifest, uploadSchema}] = await Promise.all([\n getLocalPackageVersion('sanity', workDir),\n resolveLocalPackage<typeof import('sanity')>('sanity', workDir),\n ])\n\n if (!bundleVersion) {\n throw new Error('Failed to find sanity version')\n }\n\n for (const workspace of workspaces) {\n const workspaceClient = client.withConfig({\n dataset: workspace.dataset,\n projectId: workspace.projectId,\n })\n\n try {\n debug('Uploading schema to lexicon for workspace %o', {\n dataset: workspace.dataset,\n projectId: workspace.projectId,\n })\n const descriptorId = await uploadSchema(workspace.schema, workspaceClient)\n\n if (!descriptorId) {\n throw new Error(\n `Failed to get schema descriptor ID for workspace \"${workspace.name}\": upload returned empty result`,\n )\n }\n\n schemaDescriptors.set(workspace.name, descriptorId)\n debug(\n `Uploaded schema for workspace \"${workspace.name}\" to Lexicon with descriptor ID: ${descriptorId}`,\n )\n } catch (error) {\n debug('Error uploading schema to lexicon for workspace %o', error)\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n throw new Error(\n `Failed to upload schema for workspace \"${workspace.name}\": ${errorMessage}`,\n {cause: error},\n )\n }\n }\n\n // Lazy import to avoid pulling in @sanity/ui at module load time\n const {resolveIcon} = await doImport(iconResolverPath)\n\n // Generate studio manifest using the shared utility\n const manifest = await generateStudioManifest({\n buildId: JSON.stringify(Date.now()),\n bundleVersion,\n // @todo replace with import from @sanity/schema/_internal in future\n resolveIcon: async (workspace) =>\n (await resolveIcon({\n icon: workspace.icon,\n subtitle: workspace.subtitle,\n title: workspace.title || workspace.name || 'default',\n workDir,\n })) ?? undefined,\n resolveSchemaDescriptorId: (workspace) => schemaDescriptors.get(workspace.name),\n workspaces,\n })\n\n spin.succeed('Generated studio manifest')\n\n const studioManifest = manifest.workspaces.length === 0 ? null : manifest\n\n if (verbose) {\n if (studioManifest) {\n for (const workspace of studioManifest.workspaces) {\n ux.stdout(\n styleText(\n 'gray',\n `↳ projectId: ${workspace.projectId}, dataset: ${workspace.dataset}, schemaDescriptorId: ${workspace.schemaDescriptorId}`,\n ),\n )\n }\n } else {\n ux.stdout(`${styleText('gray', '↳ No workspaces found')}`)\n }\n }\n\n return studioManifest\n } catch (error) {\n spin.fail(error instanceof Error ? error.message : 'Unknown error')\n throw error\n }\n}\n"],"names":["styleText","ux","doImport","getProjectCliClient","resolveLocalPackage","subdebug","spinner","SCHEMA_API_VERSION","getLocalPackageVersion","iconResolverPath","URL","url","href","debug","uploadSchemaToLexicon","options","projectId","verbose","workDir","workspaces","spin","start","schemaDescriptors","Map","client","apiVersion","requestTagPrefix","requireUser","bundleVersion","generateStudioManifest","uploadSchema","Promise","all","Error","workspace","workspaceClient","withConfig","dataset","descriptorId","schema","name","set","error","errorMessage","message","cause","resolveIcon","manifest","buildId","JSON","stringify","Date","now","icon","subtitle","title","undefined","resolveSchemaDescriptorId","get","succeed","studioManifest","length","stdout","schemaDescriptorId","fail"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,EAAE,QAAO,iBAAgB;AACjC,SAAQC,QAAQ,EAAEC,mBAAmB,EAAEC,mBAAmB,EAAEC,QAAQ,QAAO,mBAAkB;AAC7F,SAAQC,OAAO,QAAO,sBAAqB;AAG3C,SAAQC,kBAAkB,QAAO,4BAA2B;AAC5D,SAAQC,sBAAsB,QAAO,uCAAsC;AAE3E,MAAMC,mBAAmB,IAAIC,IAAI,+BAA+B,YAAYC,GAAG,EAAEC,IAAI;AAUrF,MAAMC,QAAQR,SAAS;AAEvB;;;;CAIC,GACD,OAAO,eAAeS,sBACpBC,OAAqC;IAErC,MAAM,EAACC,SAAS,EAAEC,OAAO,EAAEC,OAAO,EAAEC,UAAU,EAAC,GAAGJ;IAClD,MAAMK,OAAOd,QAAQ,8BAA8Be,KAAK;IAExD,IAAI;QACF,MAAMC,oBAAoB,IAAIC;QAE9B,MAAMC,SAAS,MAAMrB,oBAAoB;YACvCsB,YAAYlB;YACZS;YACAU,kBAAkB;YAClBC,aAAa;QACf;QAEA,MAAM,CAACC,e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AI;oBACpBC,UAAUpB,UAAUoB,QAAQ;oBAC5BC,OAAOrB,UAAUqB,KAAK,IAAIrB,UAAUM,IAAI,IAAI;oBAC5CtB;gBACF,MAAOsC;YACTC,2BAA2B,CAACvB,YAAcZ,kBAAkBoC,GAAG,CAACxB,UAAUM,IAAI;YAC9ErB;QACF;QAEAC,KAAKuC,OAAO,CAAC;QAEb,MAAMC,iBAAiBb,SAAS5B,UAAU,CAAC0C,MAAM,KAAK,IAAI,OAAOd;QAEjE,IAAI9B,SAAS;YACX,IAAI2C,gBAAgB;gBAClB,KAAK,MAAM1B,aAAa0B,eAAezC,UAAU,CAAE;oBACjDlB,GAAG6D,MAAM,CACP9D,UACE,QACA,CAAC,aAAa,EAAEkC,UAAUlB,SAAS,CAAC,WAAW,EAAEkB,UAAUG,OAAO,CAAC,sBAAsB,EAAEH,UAAU6B,kBAAkB,EAAE;gBAG/H;YACF,OAAO;gBACL9D,GAAG6D,MAAM,CAAC,GAAG9D,UAAU,QAAQ,0BAA0B;YAC3D;QACF;QAEA,OAAO4D;IACT,EAAE,OAAOlB,OAAO;QACdtB,KAAK4C,IAAI,CAACtB,iBAAiBT,QAAQS,MAAME,OAAO,GAAG;QACnD,MAAMF;IACR;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/schema/uploadSchemaToLexicon.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {ux} from '@oclif/core/ux'\nimport {\n doImport,\n getLocalPackageVersion,\n getProjectCliClient,\n resolveLocalPackage,\n subdebug,\n} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {type StudioManifest, type Workspace} from 'sanity'\n\nimport {SCHEMA_API_VERSION} from '../../services/schemas.js'\n\nconst iconResolverPath = new URL('../manifest/iconResolver.js', import.meta.url).href\n\ninterface UploadSchemaToLexiconOptions {\n projectId: string\n workDir: string\n workspaces: Workspace[]\n\n verbose?: boolean\n}\n\nconst debug = subdebug('uploadSchemaToLexicon')\n\n/**\n * Uploads the schemas to Lexicon and returns the studio manifest\n * @param options - The options for the uploadSchemaToLexicon function\n * @returns The studio manifest\n */\nexport async function uploadSchemaToLexicon(\n options: UploadSchemaToLexiconOptions,\n): Promise<StudioManifest | null> {\n const {projectId, verbose, workDir, workspaces} = options\n const spin = spinner('Generating studio manifest').start()\n\n try {\n const schemaDescriptors = new Map<string, string>()\n\n const client = await getProjectCliClient({\n apiVersion: SCHEMA_API_VERSION,\n projectId,\n requestTagPrefix: 'sanity.cli.deploy',\n requireUser: true,\n })\n\n const [bundleVersion, {generateStudioManifest, uploadSchema}] = await Promise.all([\n getLocalPackageVersion('sanity', workDir),\n resolveLocalPackage<typeof import('sanity')>('sanity', workDir),\n ])\n\n if (!bundleVersion) {\n throw new Error('Failed to find sanity version')\n }\n\n for (const workspace of workspaces) {\n const workspaceClient = client.withConfig({\n dataset: workspace.dataset,\n projectId: workspace.projectId,\n })\n\n try {\n debug('Uploading schema to lexicon for workspace %o', {\n dataset: workspace.dataset,\n projectId: workspace.projectId,\n })\n const descriptorId = await uploadSchema(workspace.schema, workspaceClient)\n\n if (!descriptorId) {\n throw new Error(\n `Failed to get schema descriptor ID for workspace \"${workspace.name}\": upload returned empty result`,\n )\n }\n\n schemaDescriptors.set(workspace.name, descriptorId)\n debug(\n `Uploaded schema for workspace \"${workspace.name}\" to Lexicon with descriptor ID: ${descriptorId}`,\n )\n } catch (error) {\n debug('Error uploading schema to lexicon for workspace %o', error)\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n throw new Error(\n `Failed to upload schema for workspace \"${workspace.name}\": ${errorMessage}`,\n {cause: error},\n )\n }\n }\n\n // Lazy import to avoid pulling in @sanity/ui at module load time\n const {resolveIcon} = await doImport(iconResolverPath)\n\n // Generate studio manifest using the shared utility\n const manifest = await generateStudioManifest({\n buildId: JSON.stringify(Date.now()),\n bundleVersion,\n // @todo replace with import from @sanity/schema/_internal in future\n resolveIcon: async (workspace) =>\n (await resolveIcon({\n icon: workspace.icon,\n subtitle: workspace.subtitle,\n title: workspace.title || workspace.name || 'default',\n workDir,\n })) ?? undefined,\n resolveSchemaDescriptorId: (workspace) => schemaDescriptors.get(workspace.name),\n workspaces,\n })\n\n spin.succeed('Generated studio manifest')\n\n const studioManifest = manifest.workspaces.length === 0 ? null : manifest\n\n if (verbose) {\n if (studioManifest) {\n for (const workspace of studioManifest.workspaces) {\n ux.stdout(\n styleText(\n 'gray',\n `↳ projectId: ${workspace.projectId}, dataset: ${workspace.dataset}, schemaDescriptorId: ${workspace.schemaDescriptorId}`,\n ),\n )\n }\n } else {\n ux.stdout(`${styleText('gray', '↳ No workspaces found')}`)\n }\n }\n\n return studioManifest\n } catch (error) {\n spin.fail(error instanceof Error ? error.message : 'Unknown error')\n throw error\n }\n}\n"],"names":["styleText","ux","doImport","getLocalPackageVersion","getProjectCliClient","resolveLocalPackage","subdebug","spinner","SCHEMA_API_VERSION","iconResolverPath","URL","url","href","debug","uploadSchemaToLexicon","options","projectId","verbose","workDir","workspaces","spin","start","schemaDescriptors","Map","client","apiVersion","requestTagPrefix","requireUser","bundleVersion","generateStudioManifest","uploadSchema","Promise","all","Error","workspace","workspaceClient","withConfig","dataset","descriptorId","schema","name","set","error","errorMessage","message","cause","resolveIcon","manifest","buildId","JSON","stringify","Date","now","icon","subtitle","title","undefined","resolveSchemaDescriptorId","get","succeed","studioManifest","length","stdout","schemaDescriptorId","fail"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,EAAE,QAAO,iBAAgB;AACjC,SACEC,QAAQ,EACRC,sBAAsB,EACtBC,mBAAmB,EACnBC,mBAAmB,EACnBC,QAAQ,QACH,mBAAkB;AACzB,SAAQC,OAAO,QAAO,sBAAqB;AAG3C,SAAQC,kBAAkB,QAAO,4BAA2B;AAE5D,MAAMC,mBAAmB,IAAIC,IAAI,+BAA+B,YAAYC,GAAG,EAAEC,IAAI;AAUrF,MAAMC,QAAQP,SAAS;AAEvB;;;;CAIC,GACD,OAAO,eAAeQ,sBACpB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OH;gBAAK;YAEjB;QACF;QAEA,iEAAiE;QACjE,MAAM,EAACI,WAAW,EAAC,GAAG,MAAM5C,SAASO;QAErC,oDAAoD;QACpD,MAAMsC,WAAW,MAAMlB,uBAAuB;YAC5CmB,SAASC,KAAKC,SAAS,CAACC,KAAKC,GAAG;YAChCxB;YACA,oEAAoE;YACpEkB,aAAa,OAAOZ,YAClB,AAAC,MAAMY,YAAY;oBACjBO,MAAMnB,UAAUmB,IAAI;oBACpBC,UAAUpB,UAAUoB,QAAQ;oBAC5BC,OAAOrB,UAAUqB,KAAK,IAAIrB,UAAUM,IAAI,IAAI;oBAC5CtB;gBACF,MAAOsC;YACTC,2BAA2B,CAACvB,YAAcZ,kBAAkBoC,GAAG,CAACxB,UAAUM,IAAI;YAC9ErB;QACF;QAEAC,KAAKuC,OAAO,CAAC;QAEb,MAAMC,iBAAiBb,SAAS5B,UAAU,CAAC0C,MAAM,KAAK,IAAI,OAAOd;QAEjE,IAAI9B,SAAS;YACX,IAAI2C,gBAAgB;gBAClB,KAAK,MAAM1B,aAAa0B,eAAezC,UAAU,CAAE;oBACjDlB,GAAG6D,MAAM,CACP9D,UACE,QACA,CAAC,aAAa,EAAEkC,UAAUlB,SAAS,CAAC,WAAW,EAAEkB,UAAUG,OAAO,CAAC,sBAAsB,EAAEH,UAAU6B,kBAAkB,EAAE;gBAG/H;YACF,OAAO;gBACL9D,GAAG6D,MAAM,CAAC,GAAG9D,UAAU,QAAQ,0BAA0B;YAC3D;QACF;QAEA,OAAO4D;IACT,EAAE,OAAOlB,OAAO;QACdtB,KAAK4C,IAAI,CAACtB,iBAAiBT,QAAQS,MAAME,OAAO,GAAG;QACnD,MAAMF;IACR;AACF"}
@@ -1,5 +1,5 @@
1
+ import { getLocalPackageVersion } from '@sanity/cli-core';
1
2
  import { valid } from 'semver';
2
- import { getLocalPackageVersion } from '../../util/getLocalPackageVersion.js';
3
3
  import { trimHashFromVersion } from '../../util/trimHashFromVersion.js';
4
4
  import { tryFindLatestVersion } from './tryFindLatestVersion.js';
5
5
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/versions/buildPackageArray.ts"],"sourcesContent":["import {valid} from 'semver'\n\nimport {getLocalPackageVersion} from '../../util/getLocalPackageVersion.js'\nimport {trimHashFromVersion} from '../../util/trimHashFromVersion.js'\nimport {tryFindLatestVersion} from './tryFindLatestVersion.js'\n\n/**\n * Check if a version is pinned.\n *\n * @internal\n */\nfunction isPinnedVersion(version: string): boolean {\n return !!valid(version)\n}\n\n/**\n * @internal\n */\ninterface PromisedModuleVersionInfo {\n declared: string\n installed: Promise<string | undefined>\n isGlobal: boolean\n isPinned: boolean\n latest: Promise<string | undefined>\n name: string\n}\n\n/**\n * Build an array of package versions.\n *\n * @internal\n */\nexport function buildPackageArray(\n packages: Record<string, string>,\n workDir: string,\n cliVersion: string,\n): PromisedModuleVersionInfo[] {\n const modules = []\n const latest = tryFindLatestVersion('@sanity/cli')\n modules.push({\n declared: `^${cliVersion}`,\n installed: Promise.resolve(trimHashFromVersion(cliVersion)),\n isGlobal: true,\n isPinned: false,\n latest: latest.then((version) => version),\n name: '@sanity/cli',\n })\n\n return [\n ...modules,\n ...Object.keys(packages).map((pkgName) => {\n const latest = tryFindLatestVersion(pkgName)\n const localVersion = getLocalPackageVersion(pkgName, workDir)\n return {\n declared: packages[pkgName],\n installed: localVersion.then((version) =>\n version ? trimHashFromVersion(version) : undefined,\n ),\n isGlobal: false,\n isPinned: isPinnedVersion(packages[pkgName]),\n latest: latest.then((version) => version),\n name: pkgName,\n }\n }),\n ]\n}\n"],"names":["valid","getLocalPackageVersion","trimHashFromVersion","tryFindLatestVersion","isPinnedVersion","version","buildPackageArray","packages","workDir","cliVersion","modules","latest","push","declared","installed","Promise","resolve","isGlobal","isPinned","then","name","Object","keys","map","pkgName","localVersion","undefined"],"mappings":"AAAA,SAAQA,KAAK,QAAO,SAAQ;AAE5B,SAAQC,sBAAsB,QAAO,uCAAsC;AAC3E,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,oBAAoB,QAAO,4BAA2B;AAE9D;;;;CAIC,GACD,SAASC,gBAAgBC,OAAe;IACtC,OAAO,CAAC,CAACL,MAAMK;AACjB;AAcA;;;;CAIC,GACD,OAAO,SAASC,kBACdC,QAAgC,EAChCC,OAAe,EACfC,UAAkB;IAElB,MAAMC,UAAU,EAAE;IAClB,MAAMC,SAASR,qBAAqB;IACpCO,QAAQE,IAAI,CAAC;QACXC,UAAU,CAAC,CAAC,EAAEJ,YAAY;QAC1BK,WAAWC,QAAQC,OAAO,CAACd,oBAAoBO;QAC/CQ,UAAU;QACVC,UAAU;QACVP,QAAQA,OAAOQ,IAAI,CAAC,CAACd,UAAYA;QACjCe,MAAM;IACR;IAEA,OAAO;WACFV;WACAW,OAAOC,IAAI,CAACf,UAAUgB,GAAG,CAAC,CAACC;YAC5B,MAAMb,SAASR,qBAAqBqB;YACpC,MAAMC,eAAexB,uBAAuBuB,SAAShB;YACrD,OAAO;gBACLK,UAAUN,QAAQ,CAACiB,QAAQ;gBAC3BV,WAAWW,aAAaN,IAAI,CAAC,CAACd,UAC5BA,UAAUH,oBAAoBG,WAAWqB;gBAE3CT,UAAU;gBACVC,UAAUd,gBAAgBG,QAAQ,CAACiB,QAAQ;gBAC3Cb,QAAQA,OAAOQ,IAAI,CAAC,CAACd,UAAYA;gBACjCe,MAAMI;YACR;QACF;KACD;AACH"}
1
+ {"version":3,"sources":["../../../src/actions/versions/buildPackageArray.ts"],"sourcesContent":["import {getLocalPackageVersion} from '@sanity/cli-core'\nimport {valid} from 'semver'\n\nimport {trimHashFromVersion} from '../../util/trimHashFromVersion.js'\nimport {tryFindLatestVersion} from './tryFindLatestVersion.js'\n\n/**\n * Check if a version is pinned.\n *\n * @internal\n */\nfunction isPinnedVersion(version: string): boolean {\n return !!valid(version)\n}\n\n/**\n * @internal\n */\ninterface PromisedModuleVersionInfo {\n declared: string\n installed: Promise<string | undefined>\n isGlobal: boolean\n isPinned: boolean\n latest: Promise<string | undefined>\n name: string\n}\n\n/**\n * Build an array of package versions.\n *\n * @internal\n */\nexport function buildPackageArray(\n packages: Record<string, string>,\n workDir: string,\n cliVersion: string,\n): PromisedModuleVersionInfo[] {\n const modules = []\n const latest = tryFindLatestVersion('@sanity/cli')\n modules.push({\n declared: `^${cliVersion}`,\n installed: Promise.resolve(trimHashFromVersion(cliVersion)),\n isGlobal: true,\n isPinned: false,\n latest: latest.then((version) => version),\n name: '@sanity/cli',\n })\n\n return [\n ...modules,\n ...Object.keys(packages).map((pkgName) => {\n const latest = tryFindLatestVersion(pkgName)\n const localVersion = getLocalPackageVersion(pkgName, workDir)\n return {\n declared: packages[pkgName],\n installed: localVersion.then((version) =>\n version ? trimHashFromVersion(version) : undefined,\n ),\n isGlobal: false,\n isPinned: isPinnedVersion(packages[pkgName]),\n latest: latest.then((version) => version),\n name: pkgName,\n }\n }),\n ]\n}\n"],"names":["getLocalPackageVersion","valid","trimHashFromVersion","tryFindLatestVersion","isPinnedVersion","version","buildPackageArray","packages","workDir","cliVersion","modules","latest","push","declared","installed","Promise","resolve","isGlobal","isPinned","then","name","Object","keys","map","pkgName","localVersion","undefined"],"mappings":"AAAA,SAAQA,sBAAsB,QAAO,mBAAkB;AACvD,SAAQC,KAAK,QAAO,SAAQ;AAE5B,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,oBAAoB,QAAO,4BAA2B;AAE9D;;;;CAIC,GACD,SAASC,gBAAgBC,OAAe;IACtC,OAAO,CAAC,CAACJ,MAAMI;AACjB;AAcA;;;;CAIC,GACD,OAAO,SAASC,kBACdC,QAAgC,EAChCC,OAAe,EACfC,UAAkB;IAElB,MAAMC,UAAU,EAAE;IAClB,MAAMC,SAASR,qBAAqB;IACpCO,QAAQE,IAAI,CAAC;QACXC,UAAU,CAAC,CAAC,EAAEJ,YAAY;QAC1BK,WAAWC,QAAQC,OAAO,CAACd,oBAAoBO;QAC/CQ,UAAU;QACVC,UAAU;QACVP,QAAQA,OAAOQ,IAAI,CAAC,CAACd,UAAYA;QACjCe,MAAM;IACR;IAEA,OAAO;WACFV;WACAW,OAAOC,IAAI,CAACf,UAAUgB,GAAG,CAAC,CAACC;YAC5B,MAAMb,SAASR,qBAAqBqB;YACpC,MAAMC,eAAezB,uBAAuBwB,SAAShB;YACrD,OAAO;gBACLK,UAAUN,QAAQ,CAACiB,QAAQ;gBAC3BV,WAAWW,aAAaN,IAAI,CAAC,CAACd,UAC5BA,UAAUH,oBAAoBG,WAAWqB;gBAE3CT,UAAU;gBACVC,UAAUd,gBAAgBG,QAAQ,CAACiB,QAAQ;gBAC3Cb,QAAQA,OAAOQ,IAAI,CAAC,CAACd,UAAYA;gBACjCe,MAAMI;YACR;QACF;KACD;AACH"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Root directory (relative to the project) used by Sanity tooling for
3
+ * build-time artifacts and caches — Vite's `cacheDir` and the dev-time
4
+ * manifest output. Lives under `node_modules/` so it's out of `dist` and
5
+ * ignored by default in typical `.gitignore` files.
6
+ */ export const SANITY_CACHE_DIR = 'node_modules/.sanity';
7
+
8
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["/**\n * Root directory (relative to the project) used by Sanity tooling for\n * build-time artifacts and caches — Vite's `cacheDir` and the dev-time\n * manifest output. Lives under `node_modules/` so it's out of `dist` and\n * ignored by default in typical `.gitignore` files.\n */\nexport const SANITY_CACHE_DIR = 'node_modules/.sanity'\n"],"names":["SANITY_CACHE_DIR"],"mappings":"AAAA;;;;;CAKC,GACD,OAAO,MAAMA,mBAAmB,uBAAsB"}