@sanity/cli 6.0.0-alpha.16 → 6.0.0-alpha.18

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 (152) hide show
  1. package/README.md +592 -470
  2. package/dist/SanityHelp.js +74 -21
  3. package/dist/SanityHelp.js.map +1 -1
  4. package/dist/actions/build/buildApp.js +42 -15
  5. package/dist/actions/build/buildApp.js.map +1 -1
  6. package/dist/actions/build/buildStudio.js +64 -45
  7. package/dist/actions/build/buildStudio.js.map +1 -1
  8. package/dist/actions/build/buildVendorDependencies.js +3 -16
  9. package/dist/actions/build/buildVendorDependencies.js.map +1 -1
  10. package/dist/actions/build/checkStudioDependencyVersions.js +7 -7
  11. package/dist/actions/build/checkStudioDependencyVersions.js.map +1 -1
  12. package/dist/actions/build/createExternalFromImportMap.js +1 -1
  13. package/dist/actions/build/createExternalFromImportMap.js.map +1 -1
  14. package/dist/actions/build/determineBasePath.js +5 -2
  15. package/dist/actions/build/determineBasePath.js.map +1 -1
  16. package/dist/actions/build/handlePrereleaseVersions.js +44 -0
  17. package/dist/actions/build/handlePrereleaseVersions.js.map +1 -0
  18. package/dist/actions/build/types.js.map +1 -1
  19. package/dist/actions/dataset/create.js +7 -1
  20. package/dist/actions/dataset/create.js.map +1 -1
  21. package/dist/actions/dataset/resolveDataset.js +26 -0
  22. package/dist/actions/dataset/resolveDataset.js.map +1 -0
  23. package/dist/actions/deploy/deployApp.js +1 -8
  24. package/dist/actions/deploy/deployApp.js.map +1 -1
  25. package/dist/actions/deploy/deployStudio.js +1 -0
  26. package/dist/actions/deploy/deployStudio.js.map +1 -1
  27. package/dist/actions/dev/getDevServerConfig.js +5 -2
  28. package/dist/actions/dev/getDevServerConfig.js.map +1 -1
  29. package/dist/actions/dev/startStudioDevServer.js +8 -3
  30. package/dist/actions/dev/startStudioDevServer.js.map +1 -1
  31. package/dist/actions/documents/types.js.map +1 -1
  32. package/dist/actions/documents/validate.js +11 -2
  33. package/dist/actions/documents/validate.js.map +1 -1
  34. package/dist/actions/documents/validateDocuments.worker.js +2 -2
  35. package/dist/actions/documents/validateDocuments.worker.js.map +1 -1
  36. package/dist/actions/documents/validation/reporters/jsonReporter.js +1 -1
  37. package/dist/actions/documents/validation/reporters/jsonReporter.js.map +1 -1
  38. package/dist/actions/documents/validation/reporters/ndjsonReporter.js +1 -1
  39. package/dist/actions/documents/validation/reporters/ndjsonReporter.js.map +1 -1
  40. package/dist/actions/graphql/SchemaError.js +1 -1
  41. package/dist/actions/graphql/SchemaError.js.map +1 -1
  42. package/dist/actions/graphql/__tests__/fixtures/many-self-refs.js +540 -0
  43. package/dist/actions/graphql/__tests__/fixtures/many-self-refs.js.map +1 -0
  44. package/dist/actions/graphql/__tests__/fixtures/test-studio.js +1143 -0
  45. package/dist/actions/graphql/__tests__/fixtures/test-studio.js.map +1 -0
  46. package/dist/actions/graphql/__tests__/fixtures/union-refs.js +591 -0
  47. package/dist/actions/graphql/__tests__/fixtures/union-refs.js.map +1 -0
  48. package/dist/actions/graphql/__tests__/helpers.js +23 -0
  49. package/dist/actions/graphql/__tests__/helpers.js.map +1 -0
  50. package/dist/actions/graphql/extractFromSanitySchema.js +2 -1
  51. package/dist/actions/graphql/extractFromSanitySchema.js.map +1 -1
  52. package/dist/actions/graphql/gen1/generateTypeFilters.js +1 -1
  53. package/dist/actions/graphql/gen1/generateTypeFilters.js.map +1 -1
  54. package/dist/actions/graphql/gen1/generateTypeQueries.js +2 -1
  55. package/dist/actions/graphql/gen1/generateTypeQueries.js.map +1 -1
  56. package/dist/actions/graphql/gen2/generateTypeQueries.js +1 -1
  57. package/dist/actions/graphql/gen2/generateTypeQueries.js.map +1 -1
  58. package/dist/actions/graphql/gen3/generateTypeQueries.js +1 -1
  59. package/dist/actions/graphql/gen3/generateTypeQueries.js.map +1 -1
  60. package/dist/actions/graphql/getGraphQLAPIs.js +2 -10
  61. package/dist/actions/graphql/getGraphQLAPIs.js.map +1 -1
  62. package/dist/actions/graphql/getGraphQLAPIs.worker.js +1 -1
  63. package/dist/actions/graphql/getGraphQLAPIs.worker.js.map +1 -1
  64. package/dist/actions/graphql/types.js.map +1 -1
  65. package/dist/actions/init/bootstrapLocalTemplate.js +1 -1
  66. package/dist/actions/init/bootstrapLocalTemplate.js.map +1 -1
  67. package/dist/actions/manifest/extractAppManifest.js.map +1 -1
  68. package/dist/actions/manifest/extractManifest.js +3 -22
  69. package/dist/actions/manifest/extractManifest.js.map +1 -1
  70. package/dist/actions/manifest/extractManifest.worker.js +5 -1
  71. package/dist/actions/manifest/extractManifest.worker.js.map +1 -1
  72. package/dist/actions/manifest/types.js.map +1 -1
  73. package/dist/actions/schema/deploySchemas.js +57 -80
  74. package/dist/actions/schema/deploySchemas.js.map +1 -1
  75. package/dist/actions/schema/extractSanityWorkspace.worker.js +24 -0
  76. package/dist/actions/schema/extractSanityWorkspace.worker.js.map +1 -0
  77. package/dist/actions/schema/extractSchemaWatcher.js +1 -1
  78. package/dist/actions/schema/extractSchemaWatcher.js.map +1 -1
  79. package/dist/actions/schema/types.js +4 -0
  80. package/dist/actions/schema/types.js.map +1 -1
  81. package/dist/actions/schema/uniqueWorkspaces.worker.js +3 -1
  82. package/dist/actions/schema/uniqueWorkspaces.worker.js.map +1 -1
  83. package/dist/actions/schema/utils/schemaStoreValidation.js +1 -7
  84. package/dist/actions/schema/utils/schemaStoreValidation.js.map +1 -1
  85. package/dist/actions/schema/utils/uniqByProjectIdDataset.js +1 -1
  86. package/dist/actions/schema/utils/uniqByProjectIdDataset.js.map +1 -1
  87. package/dist/actions/schema/watchExtractSchema.js +2 -1
  88. package/dist/actions/schema/watchExtractSchema.js.map +1 -1
  89. package/dist/actions/versions/getFormatters.js +1 -1
  90. package/dist/actions/versions/getFormatters.js.map +1 -1
  91. package/dist/commands/backup/list.js +4 -1
  92. package/dist/commands/backup/list.js.map +1 -1
  93. package/dist/commands/dataset/copy.js +3 -1
  94. package/dist/commands/dataset/copy.js.map +1 -1
  95. package/dist/commands/dataset/create.js +12 -0
  96. package/dist/commands/dataset/create.js.map +1 -1
  97. package/dist/commands/dataset/embeddings/disable.js +62 -0
  98. package/dist/commands/dataset/embeddings/disable.js.map +1 -0
  99. package/dist/commands/dataset/embeddings/enable.js +128 -0
  100. package/dist/commands/dataset/embeddings/enable.js.map +1 -0
  101. package/dist/commands/dataset/embeddings/status.js +61 -0
  102. package/dist/commands/dataset/embeddings/status.js.map +1 -0
  103. package/dist/commands/debug.js +2 -1
  104. package/dist/commands/debug.js.map +1 -1
  105. package/dist/commands/documents/create.js +2 -1
  106. package/dist/commands/documents/create.js.map +1 -1
  107. package/dist/commands/graphql/deploy.js +1 -1
  108. package/dist/commands/graphql/deploy.js.map +1 -1
  109. package/dist/commands/hook/logs.js +1 -1
  110. package/dist/commands/hook/logs.js.map +1 -1
  111. package/dist/commands/init.js +13 -7
  112. package/dist/commands/init.js.map +1 -1
  113. package/dist/commands/manage.js +0 -1
  114. package/dist/commands/manage.js.map +1 -1
  115. package/dist/commands/media/create-aspect.js +1 -1
  116. package/dist/commands/media/create-aspect.js.map +1 -1
  117. package/dist/commands/projects/list.js +2 -1
  118. package/dist/commands/projects/list.js.map +1 -1
  119. package/dist/commands/schema/deploy.js +11 -27
  120. package/dist/commands/schema/deploy.js.map +1 -1
  121. package/dist/commands/users/list.js +1 -1
  122. package/dist/commands/users/list.js.map +1 -1
  123. package/dist/commands/versions.js +1 -1
  124. package/dist/commands/versions.js.map +1 -1
  125. package/dist/exports/index.d.ts +62 -2
  126. package/dist/exports/index.js.map +1 -1
  127. package/dist/prompts/selectMediaLibrary.js +1 -1
  128. package/dist/prompts/selectMediaLibrary.js.map +1 -1
  129. package/dist/services/datasets.js +7 -5
  130. package/dist/services/datasets.js.map +1 -1
  131. package/dist/services/embeddings.js +25 -0
  132. package/dist/services/embeddings.js.map +1 -0
  133. package/dist/services/graphql.js.map +1 -1
  134. package/dist/services/schemas.js +1 -1
  135. package/dist/services/schemas.js.map +1 -1
  136. package/dist/types.js.map +1 -1
  137. package/dist/util/compareDependencyVersions.js +28 -7
  138. package/dist/util/compareDependencyVersions.js.map +1 -1
  139. package/dist/util/errorMessages.js +0 -1
  140. package/dist/util/errorMessages.js.map +1 -1
  141. package/dist/util/packageManager/getPeerDependencies.js +44 -0
  142. package/dist/util/packageManager/getPeerDependencies.js.map +1 -0
  143. package/oclif.manifest.json +325 -191
  144. package/package.json +19 -20
  145. package/dist/actions/schema/schemaStoreTypes.js +0 -19
  146. package/dist/actions/schema/schemaStoreTypes.js.map +0 -1
  147. package/dist/actions/schema/utils/manifestExtractor.js +0 -29
  148. package/dist/actions/schema/utils/manifestExtractor.js.map +0 -1
  149. package/dist/actions/schema/utils/manifestReader.js +0 -71
  150. package/dist/actions/schema/utils/manifestReader.js.map +0 -1
  151. package/dist/util/workerChannels.js +0 -172
  152. package/dist/util/workerChannels.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/build/buildVendorDependencies.ts"],"sourcesContent":["import path, {resolve} from 'node:path'\n\nimport semver from 'semver'\nimport {build} from 'vite'\n\nimport {getLocalPackageVersion} from '../../util/getLocalPackageVersion.js'\nimport {createExternalFromImportMap} from './createExternalFromImportMap.js'\n\n// Directory where vendor packages will be stored\nconst VENDOR_DIR = 'vendor'\n\n/**\n * A type representing the imports of vendor packages, defining specific entry\n * points for various versions and subpaths of the packages.\n *\n * The `VendorImports` object is used to build ESM browser-compatible versions\n * of the specified packages. This approach ensures that the appropriate version\n * and entry points are used for each package, enabling compatibility and proper\n * functionality in the browser environment.\n *\n * ## Rationale\n *\n * The rationale for this structure is to handle different versions of the\n * packages carefully, especially major versions. Major version bumps often\n * introduce breaking changes, so the module scheme for the package needs to be\n * checked when there is a major version update. However, minor and patch\n * versions are generally backward compatible, so they are handled more\n * leniently. By assuming that new minor versions are compatible, we avoid\n * unnecessary warnings and streamline the update process.\n *\n * If a new minor version introduces an additional subpath export within the\n * package of this version range, the corresponding package can add a more\n * specific version range that includes the new subpath. This design allows for\n * flexibility and ease of maintenance, ensuring that the latest features and\n * fixes are incorporated without extensive manual intervention.\n *\n * An additional subpath export within the package of this version range that\n * could cause the build to break if that new export is used, can be treated as\n * a bug fix. It might make more sense to our users that this new subpath isn't\n * supported yet until we address it as a bug fix. This approach helps maintain\n * stability and prevents unexpected issues during the build process.\n *\n * ## Structure\n * The `VendorImports` type is a nested object where:\n * - The keys at the first level represent the package names.\n * - The keys at the second level represent the version ranges (e.g., `^19.0.0`).\n * - The keys at the third level represent the subpaths within the package (e.g., `.` for the main entry point).\n * - The values at the third level are the relative paths to the corresponding entry points within the package.\n *\n * This structure allows for precise specification of the entry points for\n * different versions and subpaths, ensuring that the correct files are used\n * during the build process.\n */\ntype VendorImports = {\n [packageName: string]: {\n [versionRange: string]: {\n [subpath: string]: string\n }\n }\n}\n\n// Define the vendor packages and their corresponding versions and entry points\nconst VENDOR_IMPORTS: VendorImports = {\n react: {\n '^18.0.0': {\n '.': './cjs/react.production.min.js',\n './jsx-dev-runtime': './cjs/react-jsx-dev-runtime.production.min.js',\n './jsx-runtime': './cjs/react-jsx-runtime.production.min.js',\n './package.json': './package.json',\n },\n '^19.0.0': {\n '.': './cjs/react.production.js',\n './compiler-runtime': './cjs/react-compiler-runtime.production.js',\n './jsx-dev-runtime': './cjs/react-jsx-dev-runtime.production.js',\n './jsx-runtime': './cjs/react-jsx-runtime.production.js',\n './package.json': './package.json',\n },\n },\n 'react-dom': {\n '^18.0.0': {\n '.': './cjs/react-dom.production.min.js',\n './client': './cjs/react-dom.production.min.js',\n './package.json': './package.json',\n './server': './cjs/react-dom-server-legacy.browser.production.min.js',\n './server.browser': './cjs/react-dom-server-legacy.browser.production.min.js',\n },\n '^19.0.0': {\n '.': './cjs/react-dom.production.js',\n './client': './cjs/react-dom-client.production.js',\n './package.json': './package.json',\n './server': './cjs/react-dom-server-legacy.browser.production.js',\n './server.browser': './cjs/react-dom-server-legacy.browser.production.js',\n './static': './cjs/react-dom-server.browser.production.js',\n './static.browser': './cjs/react-dom-server.browser.production.js',\n },\n },\n}\n\nconst STYLED_COMPONENTS_IMPORTS = {\n 'styled-components': {\n '^6.1.0': {\n '.': './dist/styled-components.esm.js',\n './package.json': './package.json',\n },\n },\n}\n\ninterface VendorBuildOptions {\n basePath: string\n cwd: string\n isApp: boolean\n outputDir: string\n}\n\n/**\n * Builds the ESM browser compatible versions of the vendor packages\n * specified in VENDOR_IMPORTS. Returns the `imports` object of an import map.\n */\nexport async function buildVendorDependencies({\n basePath,\n cwd,\n isApp,\n outputDir,\n}: VendorBuildOptions): Promise<Record<string, string>> {\n const entry: Record<string, string> = {}\n const imports: Record<string, string> = {}\n\n // If we're building an app, we don't need to build the styled-components package\n const vendorImports = isApp ? VENDOR_IMPORTS : {...VENDOR_IMPORTS, ...STYLED_COMPONENTS_IMPORTS}\n\n // Iterate over each package and its version ranges in VENDOR_IMPORTS\n for (const [packageName, ranges] of Object.entries(vendorImports)) {\n const version = await getLocalPackageVersion(packageName, cwd)\n if (!version) {\n throw new Error(`Could not get version for '${packageName}'`)\n }\n\n // Sort version ranges in descending order\n const sortedRanges = Object.keys(ranges).toSorted((range1, range2) => {\n const min1 = semver.minVersion(range1)\n const min2 = semver.minVersion(range2)\n\n if (!min1) throw new Error(`Could not parse range '${range1}'`)\n if (!min2) throw new Error(`Could not parse range '${range2}'`)\n\n // sort them in reverse so we can rely on array `.find` below\n return semver.rcompare(min1.version, min2.version)\n })\n\n // Find the first version range that satisfies the package version\n const matchedRange = sortedRanges.find((range) => semver.satisfies(version, range))\n\n if (!matchedRange) {\n const min = semver.minVersion(sortedRanges.at(-1)!)\n if (!min) {\n throw new Error(`Could not find a minimum version for package '${packageName}'`)\n }\n\n if (semver.gt(min.version, version)) {\n throw new Error(`Package '${packageName}' requires at least ${min.version}.`)\n }\n\n throw new Error(`Version '${version}' of package '${packageName}' is not supported yet.`)\n }\n\n const subpaths = ranges[matchedRange]\n\n // Iterate over each subpath and its corresponding entry point\n for (const [subpath, relativeEntryPoint] of Object.entries(subpaths)) {\n const specifier = path.posix.join(packageName, subpath)\n const chunkName = path.posix.join(\n packageName,\n path.relative(packageName, specifier) || 'index',\n )\n\n entry[chunkName] = resolve(`node_modules/${packageName}/${relativeEntryPoint}`)\n imports[specifier] = path.posix.join('/', basePath, VENDOR_DIR, `${chunkName}.mjs`)\n }\n }\n\n // removes the `RollupWatcher` type\n type BuildResult = Exclude<Awaited<ReturnType<typeof build>>, {close: unknown}>\n\n // Use Vite to build the packages into the output directory\n let buildResult = (await build({\n appType: 'custom',\n build: {\n commonjsOptions: {strictRequires: 'auto'},\n emptyOutDir: false, // Rely on CLI to do this\n lib: {entry, formats: ['es']},\n minify: true,\n outDir: path.join(outputDir, VENDOR_DIR),\n rollupOptions: {\n external: createExternalFromImportMap({imports}),\n output: {\n chunkFileNames: '[name]-[hash].mjs',\n entryFileNames: '[name]-[hash].mjs',\n exports: 'named',\n format: 'es',\n },\n treeshake: {preset: 'recommended'},\n },\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-vendor',\n configFile: false,\n define: {'process.env.NODE_ENV': JSON.stringify('production')},\n logLevel: 'silent',\n mode: 'production',\n root: cwd,\n })) as BuildResult\n\n buildResult = Array.isArray(buildResult) ? buildResult : [buildResult]\n\n // Create a map of the original import specifiers to their hashed filenames\n const hashedImports: Record<string, string> = {}\n const output = buildResult.flatMap((i) => i.output)\n\n for (const chunk of output) {\n if (chunk.type === 'asset') continue\n\n for (const [specifier, originalPath] of Object.entries(imports)) {\n if (originalPath.endsWith(`${chunk.name}.mjs`)) {\n hashedImports[specifier] = path.posix.join('/', basePath, VENDOR_DIR, chunk.fileName)\n }\n }\n }\n\n return hashedImports\n}\n"],"names":["path","resolve","semver","build","getLocalPackageVersion","createExternalFromImportMap","VENDOR_DIR","VENDOR_IMPORTS","react","STYLED_COMPONENTS_IMPORTS","buildVendorDependencies","basePath","cwd","isApp","outputDir","entry","imports","vendorImports","packageName","ranges","Object","entries","version","Error","sortedRanges","keys","toSorted","range1","range2","min1","minVersion","min2","rcompare","matchedRange","find","range","satisfies","min","at","gt","subpaths","subpath","relativeEntryPoint","specifier","posix","join","chunkName","relative","buildResult","appType","commonjsOptions","strictRequires","emptyOutDir","lib","formats","minify","outDir","rollupOptions","external","output","chunkFileNames","entryFileNames","exports","format","treeshake","preset","cacheDir","configFile","define","JSON","stringify","logLevel","mode","root","Array","isArray","hashedImports","flatMap","i","chunk","type","originalPath","endsWith","name","fileName"],"mappings":"AAAA,OAAOA,QAAOC,OAAO,QAAO,YAAW;AAEvC,OAAOC,YAAY,SAAQ;AAC3B,SAAQC,KAAK,QAAO,OAAM;AAE1B,SAAQC,sBAAsB,QAAO,uCAAsC;AAC3E,SAAQC,2BAA2B,QAAO,mCAAkC;AAE5E,iDAAiD;AACjD,MAAMC,aAAa;AAoDnB,+EAA+E;AAC/E,MAAMC,iBAAgC;IACpCC,OAAO;QACL,WAAW;YACT,KAAK;YACL,qBAAqB;YACrB,iBAAiB;YACjB,kBAAkB;QACpB;QACA,WAAW;YACT,KAAK;YACL,sBAAsB;YACtB,qBAAqB;YACrB,iBAAiB;YACjB,kBAAkB;QACpB;IACF;IACA,aAAa;QACX,WAAW;YACT,KAAK;YACL,YAAY;YACZ,kBAAkB;YAClB,YAAY;YACZ,oBAAoB;QACtB;QACA,WAAW;YACT,KAAK;YACL,YAAY;YACZ,kBAAkB;YAClB,YAAY;YACZ,oBAAoB;YACpB,YAAY;YACZ,oBAAoB;QACtB;IACF;AACF;AAEA,MAAMC,4BAA4B;IAChC,qBAAqB;QACnB,UAAU;YACR,KAAK;YACL,kBAAkB;QACpB;IACF;AACF;AASA;;;CAGC,GACD,OAAO,eAAeC,wBAAwB,EAC5CC,QAAQ,EACRC,GAAG,EACHC,KAAK,EACLC,SAAS,EACU;IACnB,MAAMC,QAAgC,CAAC;IACvC,MAAMC,UAAkC,CAAC;IAEzC,iFAAiF;IACjF,MAAMC,gBAAgBJ,QAAQN,iB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gBAAwC,CAAC;IAC/C,MAAMjB,SAASX,YAAY6B,OAAO,CAAC,CAACC,IAAMA,EAAEnB,MAAM;IAElD,KAAK,MAAMoB,SAASpB,OAAQ;QAC1B,IAAIoB,MAAMC,IAAI,KAAK,SAAS;QAE5B,KAAK,MAAM,CAACrC,WAAWsC,aAAa,IAAI7D,OAAOC,OAAO,CAACL,SAAU;YAC/D,IAAIiE,aAAaC,QAAQ,CAAC,GAAGH,MAAMI,IAAI,CAAC,IAAI,CAAC,GAAG;gBAC9CP,aAAa,CAACjC,UAAU,GAAG3C,KAAK4C,KAAK,CAACC,IAAI,CAAC,KAAKlC,UAAUL,YAAYyE,MAAMK,QAAQ;YACtF;QACF;IACF;IAEA,OAAOR;AACT"}
1
+ {"version":3,"sources":["../../../src/actions/build/buildVendorDependencies.ts"],"sourcesContent":["import path, {resolve} from 'node:path'\n\nimport semver from 'semver'\nimport {build} from 'vite'\n\nimport {getLocalPackageVersion} from '../../util/getLocalPackageVersion.js'\nimport {createExternalFromImportMap} from './createExternalFromImportMap.js'\n\n// Directory where vendor packages will be stored\nconst VENDOR_DIR = 'vendor'\n\n/**\n * A type representing the imports of vendor packages, defining specific entry\n * points for various versions and subpaths of the packages.\n *\n * The `VendorImports` object is used to build ESM browser-compatible versions\n * of the specified packages. This approach ensures that the appropriate version\n * and entry points are used for each package, enabling compatibility and proper\n * functionality in the browser environment.\n *\n * ## Rationale\n *\n * The rationale for this structure is to handle different versions of the\n * packages carefully, especially major versions. Major version bumps often\n * introduce breaking changes, so the module scheme for the package needs to be\n * checked when there is a major version update. However, minor and patch\n * versions are generally backward compatible, so they are handled more\n * leniently. By assuming that new minor versions are compatible, we avoid\n * unnecessary warnings and streamline the update process.\n *\n * If a new minor version introduces an additional subpath export within the\n * package of this version range, the corresponding package can add a more\n * specific version range that includes the new subpath. This design allows for\n * flexibility and ease of maintenance, ensuring that the latest features and\n * fixes are incorporated without extensive manual intervention.\n *\n * An additional subpath export within the package of this version range that\n * could cause the build to break if that new export is used, can be treated as\n * a bug fix. It might make more sense to our users that this new subpath isn't\n * supported yet until we address it as a bug fix. This approach helps maintain\n * stability and prevents unexpected issues during the build process.\n *\n * ## Structure\n * The `VendorImports` type is a nested object where:\n * - The keys at the first level represent the package names.\n * - The keys at the second level represent the version ranges (e.g., `^19.0.0`).\n * - The keys at the third level represent the subpaths within the package (e.g., `.` for the main entry point).\n * - The values at the third level are the relative paths to the corresponding entry points within the package.\n *\n * This structure allows for precise specification of the entry points for\n * different versions and subpaths, ensuring that the correct files are used\n * during the build process.\n */\ntype VendorImports = {\n [packageName: string]: {\n [versionRange: string]: {\n [subpath: string]: string\n }\n }\n}\n\n// Define the vendor packages and their corresponding versions and entry points\nconst VENDOR_IMPORTS: VendorImports = {\n react: {\n '^19.2.0': {\n '.': './cjs/react.production.js',\n './compiler-runtime': './cjs/react-compiler-runtime.production.js',\n './jsx-dev-runtime': './cjs/react-jsx-dev-runtime.production.js',\n './jsx-runtime': './cjs/react-jsx-runtime.production.js',\n './package.json': './package.json',\n },\n },\n 'react-dom': {\n '^19.2.0': {\n '.': './cjs/react-dom.production.js',\n './client': './cjs/react-dom-client.production.js',\n './package.json': './package.json',\n './server': './cjs/react-dom-server-legacy.browser.production.js',\n './server.browser': './cjs/react-dom-server-legacy.browser.production.js',\n './static': './cjs/react-dom-server.browser.production.js',\n './static.browser': './cjs/react-dom-server.browser.production.js',\n },\n },\n}\n\nconst STYLED_COMPONENTS_IMPORTS = {\n 'styled-components': {\n '^6.1.0': {\n '.': './dist/styled-components.browser.esm.js',\n './package.json': './package.json',\n },\n },\n}\n\ninterface VendorBuildOptions {\n basePath: string\n cwd: string\n isApp: boolean\n outputDir: string\n}\n\n/**\n * Builds the ESM browser compatible versions of the vendor packages\n * specified in VENDOR_IMPORTS. Returns the `imports` object of an import map.\n */\nexport async function buildVendorDependencies({\n basePath,\n cwd,\n isApp,\n outputDir,\n}: VendorBuildOptions): Promise<Record<string, string>> {\n const entry: Record<string, string> = {}\n const imports: Record<string, string> = {}\n\n // If we're building an app, we don't need to build the styled-components package\n const vendorImports = isApp ? VENDOR_IMPORTS : {...VENDOR_IMPORTS, ...STYLED_COMPONENTS_IMPORTS}\n\n // Iterate over each package and its version ranges in VENDOR_IMPORTS\n for (const [packageName, ranges] of Object.entries(vendorImports)) {\n const version = await getLocalPackageVersion(packageName, cwd)\n if (!version) {\n throw new Error(`Could not get version for '${packageName}'`)\n }\n\n // Sort version ranges in descending order\n const sortedRanges = Object.keys(ranges).toSorted((range1, range2) => {\n const min1 = semver.minVersion(range1)\n const min2 = semver.minVersion(range2)\n\n if (!min1) throw new Error(`Could not parse range '${range1}'`)\n if (!min2) throw new Error(`Could not parse range '${range2}'`)\n\n // sort them in reverse so we can rely on array `.find` below\n return semver.rcompare(min1.version, min2.version)\n })\n\n // Find the first version range that satisfies the package version\n const matchedRange = sortedRanges.find((range) => semver.satisfies(version, range))\n\n if (!matchedRange) {\n const min = semver.minVersion(sortedRanges.at(-1)!)\n if (!min) {\n throw new Error(`Could not find a minimum version for package '${packageName}'`)\n }\n\n if (semver.gt(min.version, version)) {\n throw new Error(`Package '${packageName}' requires at least ${min.version}.`)\n }\n\n throw new Error(`Version '${version}' of package '${packageName}' is not supported yet.`)\n }\n\n const subpaths = ranges[matchedRange]\n\n // Iterate over each subpath and its corresponding entry point\n for (const [subpath, relativeEntryPoint] of Object.entries(subpaths)) {\n const specifier = path.posix.join(packageName, subpath)\n const chunkName = path.posix.join(\n packageName,\n path.relative(packageName, specifier) || 'index',\n )\n\n entry[chunkName] = resolve(`node_modules/${packageName}/${relativeEntryPoint}`)\n imports[specifier] = path.posix.join('/', basePath, VENDOR_DIR, `${chunkName}.mjs`)\n }\n }\n\n // removes the `RollupWatcher` type\n type BuildResult = Exclude<Awaited<ReturnType<typeof build>>, {close: unknown}>\n\n // Use Vite to build the packages into the output directory\n let buildResult = (await build({\n appType: 'custom',\n build: {\n commonjsOptions: {strictRequires: 'auto'},\n emptyOutDir: false, // Rely on CLI to do this\n lib: {entry, formats: ['es']},\n minify: true,\n outDir: path.join(outputDir, VENDOR_DIR),\n rollupOptions: {\n external: createExternalFromImportMap({imports}),\n output: {\n chunkFileNames: '[name]-[hash].mjs',\n entryFileNames: '[name]-[hash].mjs',\n exports: 'named',\n format: 'es',\n },\n treeshake: {preset: 'recommended'},\n },\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-vendor',\n configFile: false,\n define: {'process.env.NODE_ENV': JSON.stringify('production')},\n logLevel: 'silent',\n mode: 'production',\n root: cwd,\n })) as BuildResult\n\n buildResult = Array.isArray(buildResult) ? buildResult : [buildResult]\n\n // Create a map of the original import specifiers to their hashed filenames\n const hashedImports: Record<string, string> = {}\n const output = buildResult.flatMap((i) => i.output)\n\n for (const chunk of output) {\n if (chunk.type === 'asset') continue\n\n for (const [specifier, originalPath] of Object.entries(imports)) {\n if (originalPath.endsWith(`${chunk.name}.mjs`)) {\n hashedImports[specifier] = path.posix.join('/', basePath, VENDOR_DIR, chunk.fileName)\n }\n }\n }\n\n return hashedImports\n}\n"],"names":["path","resolve","semver","build","getLocalPackageVersion","createExternalFromImportMap","VENDOR_DIR","VENDOR_IMPORTS","react","STYLED_COMPONENTS_IMPORTS","buildVendorDependencies","basePath","cwd","isApp","outputDir","entry","imports","vendorImports","packageName","ranges","Object","entries","version","Error","sortedRanges","keys","toSorted","range1","range2","min1","minVersion","min2","rcompare","matchedRange","find","range","satisfies","min","at","gt","subpaths","subpath","relativeEntryPoint","specifier","posix","join","chunkName","relative","buildResult","appType","commonjsOptions","strictRequires","emptyOutDir","lib","formats","minify","outDir","rollupOptions","external","output","chunkFileNames","entryFileNames","exports","format","treeshake","preset","cacheDir","configFile","define","JSON","stringify","logLevel","mode","root","Array","isArray","hashedImports","flatMap","i","chunk","type","originalPath","endsWith","name","fileName"],"mappings":"AAAA,OAAOA,QAAOC,OAAO,QAAO,YAAW;AAEvC,OAAOC,YAAY,SAAQ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11
11
  supported: [
12
- '^18 || ^19'
12
+ '^19.2.2'
13
13
  ]
14
14
  },
15
15
  {
16
16
  deprecatedBelow: null,
17
17
  name: 'react-dom',
18
18
  supported: [
19
- '^18 || ^19'
19
+ '^19.2.2'
20
20
  ]
21
21
  },
22
22
  {
@@ -27,7 +27,7 @@ const DEFAULT_PACKAGES = [
27
27
  ]
28
28
  },
29
29
  {
30
- deprecatedBelow: null,
30
+ deprecatedBelow: '^3',
31
31
  name: '@sanity/ui',
32
32
  supported: [
33
33
  '^2',
@@ -57,10 +57,10 @@ export async function checkStudioDependencyVersions(workDir, output, { packages
57
57
  // "Untested" is usually the case where we have not upgraded the React version requirements
58
58
  // before a release, but given that is usually works in a backwards-compatible way, we want
59
59
  // to indicate that it's _untested_, not necessarily _unsupported_
60
- // Ex: Installed is react@19.0.0, but we've only _tested_ with react@^18
60
+ // Ex: Installed is react@20.0.0, but we've only _tested_ with react@^19
61
61
  const isUntested = !semver.satisfies(installed, supported) && semver.gtr(installed, supported);
62
62
  // "Unsupported" in that the installed version is _lower than_ the minimum version
63
- // Ex: Installed is react@15.0.0, but we require react@^16
63
+ // Ex: Installed is react@18.0.0, but we require react@^19.2
64
64
  const isUnsupported = !semver.satisfies(installed, supported) && !isUntested;
65
65
  // "Deprecated" in that we will stop supporting it at some point in the near future,
66
66
  // so users should be prompted to upgrade
@@ -116,7 +116,7 @@ function getUpgradeInstructions(pkgs) {
116
116
  const [highestSupported] = pkg.supported.map((version)=>(semver.coerce(version) || {
117
117
  version: ''
118
118
  }).version).toSorted(semver.rcompare);
119
- return `"${pkg.name}@${highestSupported}"`;
119
+ return `"${pkg.name}@^${highestSupported}"`;
120
120
  }).join(' ');
121
121
  return `To upgrade, run either:
122
122
 
@@ -138,7 +138,7 @@ function getDowngradeInstructions(pkgs) {
138
138
  const [highestSupported] = pkg.supported.map((version)=>(semver.coerce(version) || {
139
139
  version: ''
140
140
  }).version).toSorted(semver.rcompare);
141
- return `"${pkg.name}@${highestSupported}"`;
141
+ return `"${pkg.name}@^${highestSupported}"`;
142
142
  }).join(' ');
143
143
  return `To downgrade, run either:
144
144
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/build/checkStudioDependencyVersions.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {type Output, readPackageJson} from '@sanity/cli-core'\nimport semver, {type SemVer} from 'semver'\n\nimport {getLocalPackageVersion} from '../../util/getLocalPackageVersion.js'\n\ninterface PackageInfo {\n deprecatedBelow: string | null\n installed: SemVer\n isDeprecated: boolean\n isUnsupported: boolean\n isUntested: boolean\n name: string\n supported: string[]\n}\n\ninterface TrackedPackage {\n deprecatedBelow: string | null\n name: string\n supported: string[]\n}\n\n// NOTE: when doing changes here, also remember to update versions in help docs at\n// https://sanity.io/admin/structure/docs;helpArticle;upgrade-packages\nconst DEFAULT_PACKAGES: TrackedPackage[] = [\n {deprecatedBelow: null, name: 'react', supported: ['^18 || ^19']},\n {deprecatedBelow: null, name: 'react-dom', supported: ['^18 || ^19']},\n {deprecatedBelow: null, name: 'styled-components', supported: ['^6']},\n {deprecatedBelow: null, name: '@sanity/ui', supported: ['^2', '^3']},\n]\n\nexport async function checkStudioDependencyVersions(\n workDir: string,\n output: Output,\n {packages = DEFAULT_PACKAGES}: {packages?: TrackedPackage[]} = {},\n): Promise<void> {\n const manifest = await readPackageJson(path.join(workDir, 'package.json'), {\n skipSchemaValidation: true,\n })\n const dependencies = {...manifest?.dependencies, ...manifest?.devDependencies}\n\n const packageInfo = packages.map(async (pkg): Promise<false | PackageInfo> => {\n const dependency = dependencies[pkg.name]\n if (!dependency) {\n return false\n }\n\n const packageVersion = await getLocalPackageVersion(pkg.name, workDir)\n const installed = semver.coerce(packageVersion ?? dependency.replaceAll(/[\\D.]/g, ''))\n\n if (!installed) {\n return false\n }\n\n const supported = pkg.supported.join(' || ')\n\n // \"Untested\" is usually the case where we have not upgraded the React version requirements\n // before a release, but given that is usually works in a backwards-compatible way, we want\n // to indicate that it's _untested_, not necessarily _unsupported_\n // Ex: Installed is react@19.0.0, but we've only _tested_ with react@^18\n const isUntested = !semver.satisfies(installed, supported) && semver.gtr(installed, supported)\n\n // \"Unsupported\" in that the installed version is _lower than_ the minimum version\n // Ex: Installed is react@15.0.0, but we require react@^16\n const isUnsupported = !semver.satisfies(installed, supported) && !isUntested\n\n // \"Deprecated\" in that we will stop supporting it at some point in the near future,\n // so users should be prompted to upgrade\n const isDeprecated = pkg.deprecatedBelow ? semver.ltr(installed, pkg.deprecatedBelow) : false\n\n return {\n ...pkg,\n installed,\n isDeprecated,\n isUnsupported,\n isUntested,\n }\n })\n\n const installedPackages = (await Promise.all(packageInfo)).filter(\n (inp): inp is PackageInfo => inp !== false,\n )\n const unsupported = installedPackages.filter((pkg) => pkg.isUnsupported)\n const deprecated = installedPackages.filter((pkg) => !pkg.isUnsupported && pkg.isDeprecated)\n const untested = installedPackages.filter((pkg) => pkg.isUntested)\n\n if (deprecated.length > 0) {\n output.warn(`The following package versions have been deprecated and should be upgraded:\n\n ${listPackages(deprecated)}\n\nSupport for these will be removed in a future release!\n\n ${getUpgradeInstructions(deprecated)}\n`)\n }\n\n if (untested.length > 0) {\n output.warn(`The following package versions have not yet been marked as supported:\n\n ${listPackages(untested)}\n\nYou _may_ encounter bugs while using these versions.\n\n ${getDowngradeInstructions(untested)}\n`)\n }\n\n if (unsupported.length > 0) {\n output.error(\n `The following package versions are no longer supported and needs to be upgraded:\n\n ${listPackages(unsupported)}\n\n ${getUpgradeInstructions(unsupported)}\n`,\n {exit: 1},\n )\n }\n}\n\nfunction listPackages(pkgs: PackageInfo[]) {\n return pkgs\n .map(\n (pkg) =>\n `${pkg.name} (installed: ${pkg.installed}, want: ${\n pkg.deprecatedBelow || pkg.supported.join(' || ')\n })`,\n )\n .join('\\n ')\n}\n\nfunction getUpgradeInstructions(pkgs: PackageInfo[]) {\n const inst = pkgs\n .map((pkg) => {\n const [highestSupported] = pkg.supported\n .map((version) => (semver.coerce(version) || {version: ''}).version)\n .toSorted(semver.rcompare)\n\n return `\"${pkg.name}@${highestSupported}\"`\n })\n .join(' ')\n\n return `To upgrade, run either:\n\n npm install ${inst}\n\n or\n\n yarn add ${inst}\n\n or\n\n pnpm add ${inst}\n\n\nRead more at https://www.sanity.io/docs/help/upgrade-packages`\n}\n\nfunction getDowngradeInstructions(pkgs: PackageInfo[]) {\n const inst = pkgs\n .map((pkg) => {\n const [highestSupported] = pkg.supported\n .map((version) => (semver.coerce(version) || {version: ''}).version)\n .toSorted(semver.rcompare)\n\n return `\"${pkg.name}@${highestSupported}\"`\n })\n .join(' ')\n\n return `To downgrade, run either:\n\n yarn add ${inst}\n\n or\n\n npm install ${inst}\n\n or\n\n pnpm install ${inst}`\n}\n"],"names":["path","readPackageJson","semver","getLocalPackageVersion","DEFAULT_PACKAGES","deprecatedBelow","name","supported","checkStudioDependencyVersions","workDir","output","packages","manifest","join","skipSchemaValidation","dependencies","devDependencies","packageInfo","map","pkg","dependency","packageVersion","installed","coerce","replaceAll","isUntested","satisfies","gtr","isUnsupported","isDeprecated","ltr","installedPackages","Promise","all","filter","inp","unsupported","deprecated","untested","length","warn","listPackages","getUpgradeInstructions","getDowngradeInstructions","error","exit","pkgs","inst","highestSupported","version","toSorted","rcompare"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B,SAAqBC,eAAe,QAAO,mBAAkB;AAC7D,OAAOC,YAA2B,SAAQ;AAE1C,SAAQC,sBAAsB,QAAO,uCAAsC;AAkB3E,kFAAkF;AAClF,sEAAsE;AACtE,MAAMC,mBAAqC;IACzC;QAACC,iBAAiB;QAAMC,MAAM;QAASC,WAAW;YAAC;SAAa;IAAA;IAChE;QAACF,iBAAiB;QAAMC,MAAM;QAAaC,WAAW;YAAC;SAAa;IAAA;IACpE;QAACF,iBAAiB;QAAMC,MAAM;QAAqBC,WAAW;YAAC;SAAK;IAAA;IACpE;QAACF,iBAAiB;QAAMC,MAAM;QAAcC,WAAW;YAAC;YAAM;SAAK;IAAA;CACpE;AAED,OAA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AC,CAAC,EAAE0C,iBAAiB,CAAC,CAAC;IAC5C,GACCnC,IAAI,CAAC;IAER,OAAO,CAAC;;cAEI,EAAEkC,KAAK;;;;WAIV,EAAEA,KAAK;;;;WAIP,EAAEA,KAAK;;;6DAG2C,CAAC;AAC9D;AAEA,SAASJ,yBAAyBG,IAAmB;IACnD,MAAMC,OAAOD,KACV5B,GAAG,CAAC,CAACC;QACJ,MAAM,CAAC6B,iBAAiB,GAAG7B,IAAIZ,SAAS,CACrCW,GAAG,CAAC,CAAC+B,UAAY,AAAC/C,CAAAA,OAAOqB,MAAM,CAAC0B,YAAY;gBAACA,SAAS;YAAE,CAAA,EAAGA,OAAO,EAClEC,QAAQ,CAAChD,OAAOiD,QAAQ;QAE3B,OAAO,CAAC,CAAC,EAAEhC,IAAIb,IAAI,CAAC,CAAC,EAAE0C,iBAAiB,CAAC,CAAC;IAC5C,GACCnC,IAAI,CAAC;IAER,OAAO,CAAC;;WAEC,EAAEkC,KAAK;;;;cAIJ,EAAEA,KAAK;;;;eAIN,EAAEA,MAAM;AACvB"}
1
+ {"version":3,"sources":["../../../src/actions/build/checkStudioDependencyVersions.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {type Output, readPackageJson} from '@sanity/cli-core'\nimport semver, {type SemVer} from 'semver'\n\nimport {getLocalPackageVersion} from '../../util/getLocalPackageVersion.js'\n\ninterface PackageInfo {\n deprecatedBelow: string | null\n installed: SemVer\n isDeprecated: boolean\n isUnsupported: boolean\n isUntested: boolean\n name: string\n supported: string[]\n}\n\ninterface TrackedPackage {\n deprecatedBelow: string | null\n name: string\n supported: string[]\n}\n\n// NOTE: when doing changes here, also remember to update versions in help docs at\n// https://sanity.io/admin/structure/docs;helpArticle;upgrade-packages\nconst DEFAULT_PACKAGES: TrackedPackage[] = [\n {deprecatedBelow: null, name: 'react', supported: ['^19.2.2']},\n {deprecatedBelow: null, name: 'react-dom', supported: ['^19.2.2']},\n {deprecatedBelow: null, name: 'styled-components', supported: ['^6']},\n {deprecatedBelow: '^3', name: '@sanity/ui', supported: ['^2', '^3']},\n]\n\nexport async function checkStudioDependencyVersions(\n workDir: string,\n output: Output,\n {packages = DEFAULT_PACKAGES}: {packages?: TrackedPackage[]} = {},\n): Promise<void> {\n const manifest = await readPackageJson(path.join(workDir, 'package.json'), {\n skipSchemaValidation: true,\n })\n const dependencies = {...manifest?.dependencies, ...manifest?.devDependencies}\n\n const packageInfo = packages.map(async (pkg): Promise<false | PackageInfo> => {\n const dependency = dependencies[pkg.name]\n if (!dependency) {\n return false\n }\n\n const packageVersion = await getLocalPackageVersion(pkg.name, workDir)\n const installed = semver.coerce(packageVersion ?? dependency.replaceAll(/[\\D.]/g, ''))\n\n if (!installed) {\n return false\n }\n\n const supported = pkg.supported.join(' || ')\n\n // \"Untested\" is usually the case where we have not upgraded the React version requirements\n // before a release, but given that is usually works in a backwards-compatible way, we want\n // to indicate that it's _untested_, not necessarily _unsupported_\n // Ex: Installed is react@20.0.0, but we've only _tested_ with react@^19\n const isUntested = !semver.satisfies(installed, supported) && semver.gtr(installed, supported)\n\n // \"Unsupported\" in that the installed version is _lower than_ the minimum version\n // Ex: Installed is react@18.0.0, but we require react@^19.2\n const isUnsupported = !semver.satisfies(installed, supported) && !isUntested\n\n // \"Deprecated\" in that we will stop supporting it at some point in the near future,\n // so users should be prompted to upgrade\n const isDeprecated = pkg.deprecatedBelow ? semver.ltr(installed, pkg.deprecatedBelow) : false\n\n return {\n ...pkg,\n installed,\n isDeprecated,\n isUnsupported,\n isUntested,\n }\n })\n\n const installedPackages = (await Promise.all(packageInfo)).filter(\n (inp): inp is PackageInfo => inp !== false,\n )\n const unsupported = installedPackages.filter((pkg) => pkg.isUnsupported)\n const deprecated = installedPackages.filter((pkg) => !pkg.isUnsupported && pkg.isDeprecated)\n const untested = installedPackages.filter((pkg) => pkg.isUntested)\n\n if (deprecated.length > 0) {\n output.warn(`The following package versions have been deprecated and should be upgraded:\n\n ${listPackages(deprecated)}\n\nSupport for these will be removed in a future release!\n\n ${getUpgradeInstructions(deprecated)}\n`)\n }\n\n if (untested.length > 0) {\n output.warn(`The following package versions have not yet been marked as supported:\n\n ${listPackages(untested)}\n\nYou _may_ encounter bugs while using these versions.\n\n ${getDowngradeInstructions(untested)}\n`)\n }\n\n if (unsupported.length > 0) {\n output.error(\n `The following package versions are no longer supported and needs to be upgraded:\n\n ${listPackages(unsupported)}\n\n ${getUpgradeInstructions(unsupported)}\n`,\n {exit: 1},\n )\n }\n}\n\nfunction listPackages(pkgs: PackageInfo[]) {\n return pkgs\n .map(\n (pkg) =>\n `${pkg.name} (installed: ${pkg.installed}, want: ${\n pkg.deprecatedBelow || pkg.supported.join(' || ')\n })`,\n )\n .join('\\n ')\n}\n\nfunction getUpgradeInstructions(pkgs: PackageInfo[]) {\n const inst = pkgs\n .map((pkg) => {\n const [highestSupported] = pkg.supported\n .map((version) => (semver.coerce(version) || {version: ''}).version)\n .toSorted(semver.rcompare)\n\n return `\"${pkg.name}@^${highestSupported}\"`\n })\n .join(' ')\n\n return `To upgrade, run either:\n\n npm install ${inst}\n\n or\n\n yarn add ${inst}\n\n or\n\n pnpm add ${inst}\n\n\nRead more at https://www.sanity.io/docs/help/upgrade-packages`\n}\n\nfunction getDowngradeInstructions(pkgs: PackageInfo[]) {\n const inst = pkgs\n .map((pkg) => {\n const [highestSupported] = pkg.supported\n .map((version) => (semver.coerce(version) || {version: ''}).version)\n .toSorted(semver.rcompare)\n\n return `\"${pkg.name}@^${highestSupported}\"`\n })\n .join(' ')\n\n return `To downgrade, run either:\n\n yarn add ${inst}\n\n or\n\n npm install ${inst}\n\n or\n\n pnpm install ${inst}`\n}\n"],"names":["path","readPackageJson","semver","getLocalPackageVersion","DEFAULT_PACKAGES","deprecatedBelow","name","supported","checkStudioDependencyVersions","workDir","output","packages","manifest","join","skipSchemaValidation","dependencies","devDependencies","packageInfo","map","pkg","dependency","packageVersion","installed","coerce","replaceAll","isUntested","satisfies","gtr","isUnsupported","isDeprecated","ltr","installedPackages","Promise","all","filter","inp","unsupported","deprecated","untested","length","warn","listPackages","getUpgradeInstructions","getDowngradeInstructions","error","exit","pkgs","inst","highestSupported","version","toSorted","rcompare"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B,SAAqBC,eAAe,QAAO,mBAAkB;AAC7D,OAAOC,YAA2B,SAAQ;AAE1C,SAAQC,sBAAsB,QAAO,uCAAsC;AAkB3E,kFAAkF;AAClF,sEAAsE;AACtE,MAAMC,mBAAqC;IACzC;QAACC,iBAAiB;QAAMC,MAAM;QAASC,WAAW;YAAC;SAAU;IAAA;IAC7D;QAACF,iBAAiB;QAAMC,MAAM;QAAaC,WAAW;YAAC;SAAU;IAAA;IACjE;QAACF,iBAAiB;QAAMC,MAAM;QAAqBC,WAAW;YAAC;SAAK;IAAA;IACpE;QAACF,iBAAiB;QAAMC,MAAM;QAAcC,WAAW;YAAC;YAAM;SAAK;IAAA;CACpE;AAED,OAAO,eAAeC,8BACpBC,OAAe,EACfC,MAAc,EACd,EAACC,WAAWP,gBAAgB,EAAgC,GAAG,CAAC,CAAC;IAEjE,MAAMQ,WAAW,MAAMX,gBAAgBD,KAAKa,IAAI,CAACJ,SAAS,iBAAiB;QACzEK,sBAAsB;IACxB;IACA,MAAMC,eAAe;QAAC,GAAGH,UAAUG,YAAY;QAAE,GAAGH,UAAUI,eAAe;IAAA;IAE7E,MAAMC,cAAcN,SAASO,GAAG,CAAC,OAAOC;QACtC,MAAMC,aAAaL,YAAY,CAACI,IAAIb,IAAI,CAAC;QACzC,IAAI,CAACc,YAAY;YACf,OAAO;QACT;QAEA,MAAMC,iBAAiB,MAAMlB,uBAAuBgB,IAAIb,IAAI,EAAEG;QAC9D,MAAMa,YAAYpB,OAAOqB,MAAM,CAACF,kBAAkBD,WAAWI,UAAU,CAAC,UAAU;QAElF,IAAI,CAACF,WAAW;YACd,OAAO;QACT;QAEA,MAAMf,YAAYY,IAAIZ,SAAS,CAACM,IAAI,CAAC;QAErC,2FAA2F;QAC3F,2F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AACvB"}
@@ -1,4 +1,4 @@
1
- import { escapeRegExp } from 'lodash-es';
1
+ import escapeRegExp from 'lodash-es/escapeRegExp.js';
2
2
  /**
3
3
  * Generates a Rollup `external` configuration array based on the provided
4
4
  * import map. We derive externals from the import map because this ensures that
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/build/createExternalFromImportMap.ts"],"sourcesContent":["import {escapeRegExp} from 'lodash-es'\n\ntype ImportMap = {imports?: Record<string, string>}\n\n/**\n * Generates a Rollup `external` configuration array based on the provided\n * import map. We derive externals from the import map because this ensures that\n * modules listed in the import map are not bundled into the Rollup output so\n * the browser can load these bare specifiers according to the import map.\n */\nexport function createExternalFromImportMap({imports = {}}: ImportMap = {}): (RegExp | string)[] {\n return Object.keys(imports).map((specifier) =>\n specifier.endsWith('/') ? new RegExp(`^${escapeRegExp(specifier)}.+`) : specifier,\n )\n}\n"],"names":["escapeRegExp","createExternalFromImportMap","imports","Object","keys","map","specifier","endsWith","RegExp"],"mappings":"AAAA,SAAQA,YAAY,QAAO,YAAW;AAItC;;;;;CAKC,GACD,OAAO,SAASC,4BAA4B,EAACC,UAAU,CAAC,CAAC,EAAY,GAAG,CAAC,CAAC;IACxE,OAAOC,OAAOC,IAAI,CAACF,SAASG,GAAG,CAAC,CAACC,YAC/BA,UAAUC,QAAQ,CAAC,OAAO,IAAIC,OAAO,CAAC,CAAC,EAAER,aAAaM,WAAW,EAAE,CAAC,IAAIA;AAE5E"}
1
+ {"version":3,"sources":["../../../src/actions/build/createExternalFromImportMap.ts"],"sourcesContent":["import escapeRegExp from 'lodash-es/escapeRegExp.js'\n\ntype ImportMap = {imports?: Record<string, string>}\n\n/**\n * Generates a Rollup `external` configuration array based on the provided\n * import map. We derive externals from the import map because this ensures that\n * modules listed in the import map are not bundled into the Rollup output so\n * the browser can load these bare specifiers according to the import map.\n */\nexport function createExternalFromImportMap({imports = {}}: ImportMap = {}): (RegExp | string)[] {\n return Object.keys(imports).map((specifier) =>\n specifier.endsWith('/') ? new RegExp(`^${escapeRegExp(specifier)}.+`) : specifier,\n )\n}\n"],"names":["escapeRegExp","createExternalFromImportMap","imports","Object","keys","map","specifier","endsWith","RegExp"],"mappings":"AAAA,OAAOA,kBAAkB,4BAA2B;AAIpD;;;;;CAKC,GACD,OAAO,SAASC,4BAA4B,EAACC,UAAU,CAAC,CAAC,EAAY,GAAG,CAAC,CAAC;IACxE,OAAOC,OAAOC,IAAI,CAACF,SAASG,GAAG,CAAC,CAACC,YAC/BA,UAAUC,QAAQ,CAAC,OAAO,IAAIC,OAAO,CAAC,CAAC,EAAER,aAAaM,WAAW,EAAE,CAAC,IAAIA;AAE5E"}
@@ -2,18 +2,21 @@
2
2
  * Finds the basepath given conditions
3
3
  *
4
4
  * @internal
5
- */ export function determineBasePath(cliConfig, type) {
5
+ */ export function determineBasePath(cliConfig, type, output) {
6
6
  // Determine base path for built studio
7
7
  let basePath = '/';
8
8
  const envBasePath = type === 'app' ? process.env.SANITY_APP_BASEPATH : process.env.SANITY_STUDIO_BASEPATH;
9
9
  const configBasePath = cliConfig?.project?.basePath;
10
10
  if (envBasePath) {
11
- // Environment variable (SANITY_APP_BASEPATH)
11
+ // Environment variable (SANITY_APP_BASEPATH or SANITY_STUDIO_BASEPATH)
12
12
  basePath = envBasePath;
13
13
  } else if (configBasePath) {
14
14
  // `sanity.cli.ts`
15
15
  basePath = configBasePath;
16
16
  }
17
+ if (envBasePath && configBasePath && output) {
18
+ output.warn(`Overriding configured base path (${configBasePath}) with value from environment variable (${envBasePath})`);
19
+ }
17
20
  return basePath;
18
21
  }
19
22
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/build/determineBasePath.ts"],"sourcesContent":["import {type CliConfig} from '@sanity/cli-core'\n\n/**\n * Finds the basepath given conditions\n *\n * @internal\n */\nexport function determineBasePath(cliConfig: CliConfig, type: 'app' | 'studio'): string {\n // Determine base path for built studio\n let basePath = '/'\n const envBasePath =\n type === 'app' ? process.env.SANITY_APP_BASEPATH : process.env.SANITY_STUDIO_BASEPATH\n const configBasePath = cliConfig?.project?.basePath\n\n if (envBasePath) {\n // Environment variable (SANITY_APP_BASEPATH)\n basePath = envBasePath\n } else if (configBasePath) {\n // `sanity.cli.ts`\n basePath = configBasePath\n }\n\n return basePath\n}\n"],"names":["determineBasePath","cliConfig","type","basePath","envBasePath","process","env","SANITY_APP_BASEPATH","SANITY_STUDIO_BASEPATH","configBasePath","project"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,SAASA,kBAAkBC,SAAoB,EAAEC,IAAsB;IAC5E,uCAAuC;IACvC,IAAIC,WAAW;IACf,MAAMC,cACJF,SAAS,QAAQG,QAAQC,GAAG,CAACC,mBAAmB,GAAGF,QAAQC,GAAG,CAACE,sBAAsB;IACvF,MAAMC,iBAAiBR,WAAWS,SAASP;IAE3C,IAAIC,aAAa;QACf,6CAA6C;QAC7CD,WAAWC;IACb,OAAO,IAAIK,gBAAgB;QACzB,kBAAkB;QAClBN,WAAWM;IACb;IAEA,OAAON;AACT"}
1
+ {"version":3,"sources":["../../../src/actions/build/determineBasePath.ts"],"sourcesContent":["import {type CliConfig, type Output} from '@sanity/cli-core'\n\n/**\n * Finds the basepath given conditions\n *\n * @internal\n */\nexport function determineBasePath(\n cliConfig: CliConfig,\n type: 'app' | 'studio',\n output?: Output,\n): string {\n // Determine base path for built studio\n let basePath = '/'\n const envBasePath =\n type === 'app' ? process.env.SANITY_APP_BASEPATH : process.env.SANITY_STUDIO_BASEPATH\n const configBasePath = cliConfig?.project?.basePath\n\n if (envBasePath) {\n // Environment variable (SANITY_APP_BASEPATH or SANITY_STUDIO_BASEPATH)\n basePath = envBasePath\n } else if (configBasePath) {\n // `sanity.cli.ts`\n basePath = configBasePath\n }\n\n if (envBasePath && configBasePath && output) {\n output.warn(\n `Overriding configured base path (${configBasePath}) with value from environment variable (${envBasePath})`,\n )\n }\n\n return basePath\n}\n"],"names":["determineBasePath","cliConfig","type","output","basePath","envBasePath","process","env","SANITY_APP_BASEPATH","SANITY_STUDIO_BASEPATH","configBasePath","project","warn"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,SAASA,kBACdC,SAAoB,EACpBC,IAAsB,EACtBC,MAAe;IAEf,uCAAuC;IACvC,IAAIC,WAAW;IACf,MAAMC,cACJH,SAAS,QAAQI,QAAQC,GAAG,CAACC,mBAAmB,GAAGF,QAAQC,GAAG,CAACE,sBAAsB;IACvF,MAAMC,iBAAiBT,WAAWU,SAASP;IAE3C,IAAIC,aAAa;QACf,uEAAuE;QACvED,WAAWC;IACb,OAAO,IAAIK,gBAAgB;QACzB,kBAAkB;QAClBN,WAAWM;IACb;IAEA,IAAIL,eAAeK,kBAAkBP,QAAQ;QAC3CA,OAAOS,IAAI,CACT,CAAC,iCAAiC,EAAEF,eAAe,wCAAwC,EAAEL,YAAY,CAAC,CAAC;IAE/G;IAEA,OAAOD;AACT"}
@@ -0,0 +1,44 @@
1
+ import { styleText } from 'node:util';
2
+ import { isInteractive } from '@sanity/cli-core';
3
+ import { select } from '@sanity/cli-core/ux';
4
+ /**
5
+ * Handle prerelease versions that cannot be resolved by the auto-updates CDN.
6
+ *
7
+ * In unattended or non-interactive mode, exits with an error. In interactive mode,
8
+ * prompts the user to either disable auto-updates for this build or cancel.
9
+ *
10
+ * Does not return if the build should be cancelled (exits via `output.error`).
11
+ */ export async function handlePrereleaseVersions({ output, unattendedMode, unresolvedPrerelease }) {
12
+ const prereleaseMessage = `The following packages are using prerelease versions not yet available on the auto-updates CDN:\n\n` + `${unresolvedPrerelease.map((mod)=>` - ${mod.pkg} (${mod.version})`).join('\n')}\n\n` + `Auto-updates cannot be used with prerelease versions. To re-enable auto-updates later, ` + `switch to a non-prerelease version locally and deploy again.`;
13
+ if (unattendedMode || !isInteractive()) {
14
+ output.error(`${prereleaseMessage}\n\n` + `Cannot build with auto-updates in unattended mode when using prerelease versions. ` + `Either switch to a non-prerelease version, or use --no-auto-updates to build without auto-updates.`, {
15
+ exit: 1
16
+ });
17
+ // output.error with exit: 1 throws, but TypeScript doesn't know that
18
+ throw new Error('unreachable');
19
+ }
20
+ const choice = await select({
21
+ choices: [
22
+ {
23
+ name: 'Disable auto-updates for this build and continue',
24
+ value: 'disable-auto-updates'
25
+ },
26
+ {
27
+ name: 'Cancel build',
28
+ value: 'cancel'
29
+ }
30
+ ],
31
+ default: 'disable-auto-updates',
32
+ message: styleText('yellow', prereleaseMessage)
33
+ });
34
+ if (choice === 'cancel') {
35
+ output.error('Declined to continue with build', {
36
+ exit: 1
37
+ });
38
+ // output.error with exit: 1 throws, but TypeScript doesn't know that
39
+ throw new Error('unreachable');
40
+ }
41
+ output.warn('Auto-updates disabled for this build');
42
+ }
43
+
44
+ //# sourceMappingURL=handlePrereleaseVersions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/actions/build/handlePrereleaseVersions.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {isInteractive, type Output} from '@sanity/cli-core'\nimport {select} from '@sanity/cli-core/ux'\n\nimport {type UnresolvedPrerelease} from '../../util/compareDependencyVersions.js'\n\n/**\n * Handle prerelease versions that cannot be resolved by the auto-updates CDN.\n *\n * In unattended or non-interactive mode, exits with an error. In interactive mode,\n * prompts the user to either disable auto-updates for this build or cancel.\n *\n * Does not return if the build should be cancelled (exits via `output.error`).\n */\nexport async function handlePrereleaseVersions({\n output,\n unattendedMode,\n unresolvedPrerelease,\n}: {\n output: Output\n unattendedMode: boolean\n unresolvedPrerelease: UnresolvedPrerelease[]\n}): Promise<void> {\n const prereleaseMessage =\n `The following packages are using prerelease versions not yet available on the auto-updates CDN:\\n\\n` +\n `${unresolvedPrerelease.map((mod) => ` - ${mod.pkg} (${mod.version})`).join('\\n')}\\n\\n` +\n `Auto-updates cannot be used with prerelease versions. To re-enable auto-updates later, ` +\n `switch to a non-prerelease version locally and deploy again.`\n\n if (unattendedMode || !isInteractive()) {\n output.error(\n `${prereleaseMessage}\\n\\n` +\n `Cannot build with auto-updates in unattended mode when using prerelease versions. ` +\n `Either switch to a non-prerelease version, or use --no-auto-updates to build without auto-updates.`,\n {exit: 1},\n )\n // output.error with exit: 1 throws, but TypeScript doesn't know that\n throw new Error('unreachable')\n }\n\n const choice = await select({\n choices: [\n {\n name: 'Disable auto-updates for this build and continue',\n value: 'disable-auto-updates',\n },\n {name: 'Cancel build', value: 'cancel'},\n ],\n default: 'disable-auto-updates',\n message: styleText('yellow', prereleaseMessage),\n })\n\n if (choice === 'cancel') {\n output.error('Declined to continue with build', {exit: 1})\n // output.error with exit: 1 throws, but TypeScript doesn't know that\n throw new Error('unreachable')\n }\n\n output.warn('Auto-updates disabled for this build')\n}\n"],"names":["styleText","isInteractive","select","handlePrereleaseVersions","output","unattendedMode","unresolvedPrerelease","prereleaseMessage","map","mod","pkg","version","join","error","exit","Error","choice","choices","name","value","default","message","warn"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,aAAa,QAAoB,mBAAkB;AAC3D,SAAQC,MAAM,QAAO,sBAAqB;AAI1C;;;;;;;CAOC,GACD,OAAO,eAAeC,yBAAyB,EAC7CC,MAAM,EACNC,cAAc,EACdC,oBAAoB,EAKrB;IACC,MAAMC,oBACJ,CAAC,mGAAmG,CAAC,GACrG,GAAGD,qBAAqBE,GAAG,CAAC,CAACC,MAAQ,CAAC,GAAG,EAAEA,IAAIC,GAAG,CAAC,EAAE,EAAED,IAAIE,OAAO,CAAC,CAAC,CAAC,EAAEC,IAAI,CAAC,MAAM,IAAI,CAAC,GACvF,CAAC,uFAAuF,CAAC,GACzF,CAAC,4DAA4D,CAAC;IAEhE,IAAIP,kBAAkB,CAACJ,iBAAiB;QACtCG,OAAOS,KAAK,CACV,GAAGN,kBAAkB,IAAI,CAAC,GACxB,CAAC,kFAAkF,CAAC,GACpF,CAAC,kGAAkG,CAAC,EACtG;YAACO,MAAM;QAAC;QAEV,qEAAqE;QACrE,MAAM,IAAIC,MAAM;IAClB;IAEA,MAAMC,SAAS,MAAMd,OAAO;QAC1Be,SAAS;YACP;gBACEC,MAAM;gBACNC,OAAO;YACT;YACA;gBAACD,MAAM;gBAAgBC,OAAO;YAAQ;SACvC;QACDC,SAAS;QACTC,SAASrB,UAAU,UAAUO;IAC/B;IAEA,IAAIS,WAAW,UAAU;QACvBZ,OAAOS,KAAK,CAAC,mCAAmC;YAACC,MAAM;QAAC;QACxD,qEAAqE;QACrE,MAAM,IAAIC,MAAM;IAClB;IAEAX,OAAOkB,IAAI,CAAC;AACd"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/build/types.ts"],"sourcesContent":["import {type CliConfig, type Output} from '@sanity/cli-core'\n\nimport {BuildCommand} from '../../commands/build.js'\nimport {type DeployFlags} from '../deploy/types.js'\n\nexport type BuildFlags = BuildCommand['flags']\n\nexport interface BuildOptions {\n autoUpdatesEnabled: boolean\n cliConfig: CliConfig\n flags: BuildFlags | DeployFlags\n output: Output\n\n workDir: string\n\n outDir?: string\n}\n"],"names":[],"mappings":"AAOA,WASC"}
1
+ {"version":3,"sources":["../../../src/actions/build/types.ts"],"sourcesContent":["import {type CliConfig, type Output} from '@sanity/cli-core'\n\nimport {BuildCommand} from '../../commands/build.js'\nimport {type DeployFlags} from '../deploy/types.js'\n\nexport type BuildFlags = BuildCommand['flags']\n\nexport interface BuildOptions {\n autoUpdatesEnabled: boolean\n cliConfig: CliConfig\n flags: BuildFlags | DeployFlags\n output: Output\n\n workDir: string\n\n calledFromDeploy?: boolean\n outDir?: string\n}\n"],"names":[],"mappings":"AAOA,WAUC"}
@@ -15,7 +15,7 @@ const debug = subdebug('dataset:create');
15
15
  * @returns Promise resolving when dataset is created
16
16
  * @throws Error if dataset creation fails
17
17
  */ export async function createDataset(options) {
18
- const { datasetName, forcePublic = false, isUnattended = false, output, projectFeatures, projectId, visibility } = options;
18
+ const { datasetName, embeddings, embeddingsProjection, forcePublic = false, isUnattended = false, output, projectFeatures, projectId, visibility } = options;
19
19
  const canCreatePrivate = projectFeatures.includes('privateDataset') && !forcePublic;
20
20
  // Determine the appropriate ACL mode
21
21
  const aclMode = await determineDatasetAclMode({
@@ -29,6 +29,12 @@ const debug = subdebug('dataset:create');
29
29
  const newDataset = await createDatasetService({
30
30
  aclMode,
31
31
  datasetName,
32
+ embeddings: embeddings ? {
33
+ enabled: true,
34
+ ...embeddingsProjection ? {
35
+ projection: embeddingsProjection
36
+ } : {}
37
+ } : undefined,
32
38
  projectId
33
39
  });
34
40
  spin.succeed();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/dataset/create.ts"],"sourcesContent":["import {type Output, subdebug} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {type DatasetAclMode, DatasetResponse} from '@sanity/client'\n\nimport {createDataset as createDatasetService} from '../../services/datasets.js'\nimport {determineDatasetAclMode} from './determineDatasetAclMode.js'\n\nconst debug = subdebug('dataset:create')\n\n/**\n * Options for creating a dataset\n */\ninterface CreateDatasetOptions {\n /**\n * Name of the dataset to create\n */\n datasetName: string\n\n /**\n * Output instance for logging\n */\n output: Output\n\n /**\n * Array of project features to determine capabilities\n * Used to check if private datasets are available\n */\n projectFeatures: string[]\n\n /**\n * Project ID where the dataset will be created\n */\n projectId: string\n\n /**\n * Whether to force disable private dataset creation\n * Used when default config is selected (which forces public datasets)\n */\n forcePublic?: boolean\n\n /**\n * Whether to run in unattended mode (no prompts)\n */\n isUnattended?: boolean\n\n /**\n * Requested visibility mode from flags/options\n */\n visibility?: string\n}\n\n/**\n * Creates a new dataset with the appropriate ACL mode.\n *\n * This action handles the business logic for:\n * - Determining the appropriate ACL mode based on project capabilities\n * - Creating the dataset via the service layer\n * - Handling errors and providing user feedback\n *\n * @param options - Configuration options\n * @returns Promise resolving when dataset is created\n * @throws Error if dataset creation fails\n */\nexport async function createDataset(options: CreateDatasetOptions): Promise<DatasetResponse> {\n const {\n datasetName,\n forcePublic = false,\n isUnattended = false,\n output,\n projectFeatures,\n projectId,\n visibility,\n } = options\n\n const canCreatePrivate = projectFeatures.includes('privateDataset') && !forcePublic\n\n // Determine the appropriate ACL mode\n const aclMode: DatasetAclMode = await determineDatasetAclMode({\n canCreatePrivate,\n isUnattended,\n output,\n visibility,\n })\n\n try {\n const spin = spinner('Creating dataset').start()\n const newDataset = await createDatasetService({\n aclMode,\n datasetName,\n projectId,\n })\n spin.succeed()\n output.log(`Dataset created successfully`)\n return newDataset\n } catch (error) {\n debug('Error creating dataset', {datasetName, error})\n throw error\n }\n}\n"],"names":["subdebug","spinner","createDataset","createDatasetService","determineDatasetAclMode","debug","options","datasetName","forcePublic","isUnattended","output","projectFeatures","projectId","visibility","canCreatePrivate","includes","aclMode","spin","start","newDataset","succeed","log","error"],"mappings":"AAAA,SAAqBA,QAAQ,QAAO,mBAAkB;AACtD,SAAQC,OAAO,QAAO,sBAAqB;AAG3C,SAAQC,iBAAiBC,oBAAoB,QAAO,6BAA4B;AAChF,SAAQC,uBAAuB,QAAO,+BAA8B;AAEpE,MAAMC,QAAQL,SAAS;AA4CvB;;;;;;;;;;;CAWC,GACD,OAAO,eAAeE,cAAcI,OAA6B;IAC/D,MAAM,EACJC,WAAW,EACXC,cAAc,KAAK,EACnBC,eAAe,KAAK,EACpBC,MAAM,EACNC,eAAe,EACfC,SAAS,EACTC,UAAU,EACX,GAAGP;IAEJ,MAAMQ,mBAAmBH,gBAAgBI,QAAQ,CAAC,qBAAqB,CAACP;IAExE,qCAAqC;IACrC,MAAMQ,UAA0B,MAAMZ,wBAAwB;QAC5DU;QACAL;QACAC;QACAG;IACF;IAEA,IAAI;QACF,MAAMI,OAAOhB,QAAQ,oBAAoBiB,KAAK;QAC9C,MAAMC,aAAa,MAAMhB,qBAAqB;YAC5Ca;YACAT;YACAK;QACF;QACAK,KAAKG,OAAO;QACZV,OAAOW,GAAG,CAAC,CAAC,4BAA4B,CAAC;QACzC,OAAOF;IACT,EAAE,OAAOG,OAAO;QACdjB,MAAM,0BAA0B;YAACE;YAAae;QAAK;QACnD,MAAMA;IACR;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/dataset/create.ts"],"sourcesContent":["import {type Output, subdebug} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {type DatasetAclMode, DatasetResponse} from '@sanity/client'\n\nimport {createDataset as createDatasetService} from '../../services/datasets.js'\nimport {determineDatasetAclMode} from './determineDatasetAclMode.js'\n\nconst debug = subdebug('dataset:create')\n\n/**\n * Options for creating a dataset\n */\ninterface CreateDatasetOptions {\n /**\n * Name of the dataset to create\n */\n datasetName: string\n\n /**\n * Output instance for logging\n */\n output: Output\n\n /**\n * Array of project features to determine capabilities\n * Used to check if private datasets are available\n */\n projectFeatures: string[]\n\n /**\n * Project ID where the dataset will be created\n */\n projectId: string\n\n /**\n * Whether to enable embeddings for the new dataset\n */\n embeddings?: boolean\n\n /**\n * GROQ projection for embeddings indexing (e.g. \"\\{ title, body \\}\")\n * Only used when embeddings is true\n */\n embeddingsProjection?: string\n\n /**\n * Whether to force disable private dataset creation\n * Used when default config is selected (which forces public datasets)\n */\n forcePublic?: boolean\n\n /**\n * Whether to run in unattended mode (no prompts)\n */\n isUnattended?: boolean\n\n /**\n * Requested visibility mode from flags/options\n */\n visibility?: string\n}\n\n/**\n * Creates a new dataset with the appropriate ACL mode.\n *\n * This action handles the business logic for:\n * - Determining the appropriate ACL mode based on project capabilities\n * - Creating the dataset via the service layer\n * - Handling errors and providing user feedback\n *\n * @param options - Configuration options\n * @returns Promise resolving when dataset is created\n * @throws Error if dataset creation fails\n */\nexport async function createDataset(options: CreateDatasetOptions): Promise<DatasetResponse> {\n const {\n datasetName,\n embeddings,\n embeddingsProjection,\n forcePublic = false,\n isUnattended = false,\n output,\n projectFeatures,\n projectId,\n visibility,\n } = options\n\n const canCreatePrivate = projectFeatures.includes('privateDataset') && !forcePublic\n\n // Determine the appropriate ACL mode\n const aclMode: DatasetAclMode = await determineDatasetAclMode({\n canCreatePrivate,\n isUnattended,\n output,\n visibility,\n })\n\n try {\n const spin = spinner('Creating dataset').start()\n const newDataset = await createDatasetService({\n aclMode,\n datasetName,\n embeddings: embeddings\n ? {enabled: true, ...(embeddingsProjection ? {projection: embeddingsProjection} : {})}\n : undefined,\n projectId,\n })\n spin.succeed()\n output.log(`Dataset created successfully`)\n return newDataset\n } catch (error) {\n debug('Error creating dataset', {datasetName, error})\n throw error\n }\n}\n"],"names":["subdebug","spinner","createDataset","createDatasetService","determineDatasetAclMode","debug","options","datasetName","embeddings","embeddingsProjection","forcePublic","isUnattended","output","projectFeatures","projectId","visibility","canCreatePrivate","includes","aclMode","spin","start","newDataset","enabled","projection","undefined","succeed","log","error"],"mappings":"AAAA,SAAqBA,QAAQ,QAAO,mBAAkB;AACtD,SAAQC,OAAO,QAAO,sBAAqB;AAG3C,SAAQC,iBAAiBC,oBAAoB,QAAO,6BAA4B;AAChF,SAAQC,uBAAuB,QAAO,+BAA8B;AAEpE,MAAMC,QAAQL,SAAS;AAuDvB;;;;;;;;;;;CAWC,GACD,OAAO,eAAeE,cAAcI,OAA6B;IAC/D,MAAM,EACJC,WAAW,EACXC,UAAU,EACVC,oBAAoB,EACpBC,cAAc,KAAK,EACnBC,eAAe,KAAK,EACpBC,MAAM,EACNC,eAAe,EACfC,SAAS,EACTC,UAAU,EACX,GAAGT;IAEJ,MAAMU,mBAAmBH,gBAAgBI,QAAQ,CAAC,qBAAqB,CAACP;IAExE,qCAAqC;IACrC,MAAMQ,UAA0B,MAAMd,wBAAwB;QAC5DY;QACAL;QACAC;QACAG;IACF;IAEA,IAAI;QACF,MAAMI,OAAOlB,QAAQ,oBAAoBmB,KAAK;QAC9C,MAAMC,aAAa,MAAMlB,qBAAqB;YAC5Ce;YACAX;YACAC,YAAYA,aACR;gBAACc,SAAS;gBAAM,GAAIb,uBAAuB;oBAACc,YAAYd;gBAAoB,IAAI,CAAC,CAAC;YAAC,IACnFe;YACJV;QACF;QACAK,KAAKM,OAAO;QACZb,OAAOc,GAAG,CAAC,CAAC,4BAA4B,CAAC;QACzC,OAAOL;IACT,EAAE,OAAOM,OAAO;QACdtB,MAAM,0BAA0B;YAACE;YAAaoB;QAAK;QACnD,MAAMA;IACR;AACF"}
@@ -0,0 +1,26 @@
1
+ import { promptForDataset } from '../../prompts/promptForDataset.js';
2
+ import { listDatasets } from '../../services/datasets.js';
3
+ import { assertDatasetExists } from '../backup/assertDatasetExist.js';
4
+ /**
5
+ * Lists datasets for a project, validates the given dataset name (or prompts
6
+ * the user to pick one), and returns the resolved name together with the full
7
+ * dataset list.
8
+ */ export async function resolveDataset({ dataset, projectId }) {
9
+ const datasets = await listDatasets(projectId);
10
+ if (datasets.length === 0) {
11
+ throw new Error('No datasets found in this project.');
12
+ }
13
+ if (dataset) {
14
+ assertDatasetExists(datasets, dataset);
15
+ } else {
16
+ dataset = await promptForDataset({
17
+ datasets
18
+ });
19
+ }
20
+ return {
21
+ dataset,
22
+ datasets
23
+ };
24
+ }
25
+
26
+ //# sourceMappingURL=resolveDataset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/actions/dataset/resolveDataset.ts"],"sourcesContent":["import {type DatasetsResponse} from '@sanity/client'\n\nimport {promptForDataset} from '../../prompts/promptForDataset.js'\nimport {listDatasets} from '../../services/datasets.js'\nimport {assertDatasetExists} from '../backup/assertDatasetExist.js'\n\ninterface ResolveDatasetOptions {\n projectId: string\n\n dataset?: string\n}\n\ninterface ResolveDatasetResult {\n dataset: string\n datasets: DatasetsResponse\n}\n\n/**\n * Lists datasets for a project, validates the given dataset name (or prompts\n * the user to pick one), and returns the resolved name together with the full\n * dataset list.\n */\nexport async function resolveDataset({\n dataset,\n projectId,\n}: ResolveDatasetOptions): Promise<ResolveDatasetResult> {\n const datasets = await listDatasets(projectId)\n\n if (datasets.length === 0) {\n throw new Error('No datasets found in this project.')\n }\n\n if (dataset) {\n assertDatasetExists(datasets, dataset)\n } else {\n dataset = await promptForDataset({datasets})\n }\n\n return {dataset, datasets}\n}\n"],"names":["promptForDataset","listDatasets","assertDatasetExists","resolveDataset","dataset","projectId","datasets","length","Error"],"mappings":"AAEA,SAAQA,gBAAgB,QAAO,oCAAmC;AAClE,SAAQC,YAAY,QAAO,6BAA4B;AACvD,SAAQC,mBAAmB,QAAO,kCAAiC;AAanE;;;;CAIC,GACD,OAAO,eAAeC,eAAe,EACnCC,OAAO,EACPC,SAAS,EACa;IACtB,MAAMC,WAAW,MAAML,aAAaI;IAEpC,IAAIC,SAASC,MAAM,KAAK,GAAG;QACzB,MAAM,IAAIC,MAAM;IAClB;IAEA,IAAIJ,SAAS;QACXF,oBAAoBI,UAAUF;IAChC,OAAO;QACLA,UAAU,MAAMJ,iBAAiB;YAACM;QAAQ;IAC5C;IAEA,OAAO;QAACF;QAASE;IAAQ;AAC3B"}
@@ -8,7 +8,6 @@ import { createDeployment } from '../../services/userApplications.js';
8
8
  import { getAppId } from '../../util/appId.js';
9
9
  import { NO_ORGANIZATION_ID } from '../../util/errorMessages.js';
10
10
  import { getLocalPackageVersion } from '../../util/getLocalPackageVersion.js';
11
- import { warnAboutMissingAppId } from '../../util/warnAboutMissingAppId.js';
12
11
  import { buildApp } from '../build/buildApp.js';
13
12
  import { shouldAutoUpdate } from '../build/shouldAutoUpdate.js';
14
13
  import { extractAppManifest } from '../manifest/extractAppManifest.js';
@@ -55,19 +54,13 @@ import { findUserApplicationForApp } from './findUserApplicationForApp.js';
55
54
  userApplication = await createUserApplicationForApp(organizationId);
56
55
  deployDebug(`User application created`, userApplication);
57
56
  }
58
- // Warn about missing app ID if auto updates are enabled
59
- if (isAutoUpdating && !appId) {
60
- warnAboutMissingAppId({
61
- appType: 'app',
62
- output
63
- });
64
- }
65
57
  // Always build the project, unless --no-build is passed
66
58
  const shouldBuild = flags.build;
67
59
  if (shouldBuild) {
68
60
  deployDebug(`Building app`);
69
61
  await buildApp({
70
62
  autoUpdatesEnabled: isAutoUpdating,
63
+ calledFromDeploy: true,
71
64
  cliConfig,
72
65
  flags,
73
66
  outDir: sourceDir,
@@ -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} from '../../services/userApplications.js'\nimport {getAppId} from '../../util/appId.js'\nimport {NO_ORGANIZATION_ID} from '../../util/errorMessages.js'\nimport {getLocalPackageVersion} from '../../util/getLocalPackageVersion.js'\nimport {warnAboutMissingAppId} from '../../util/warnAboutMissingAppId.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, sourceDir, workDir} = options\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 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 // Warn about missing app ID if auto updates are enabled\n if (isAutoUpdating && !appId) {\n warnAboutMissingAppId({appType: 'app', output})\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 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({flags, workDir})\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n deployDebug('Error extracting app manifest', err)\n output.warn(`Error extracting app manifest: ${message}`)\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","getAppId","NO_ORGANIZATION_ID","getLocalPackageVersion","warnAboutMissingAppId","buildApp","shouldAutoUpdate","extractAppManifest","checkDir","createUserApplicationForApp","deployDebug","findUserApplicationForApp","deployApp","options","cliConfig","flags","output","sourceDir","workDir","organizationId","app","appId","isAutoUpdating","installedSdkVersion","error","exit","spin","userApplication","appType","shouldBuild","build","autoUpdatesEnabled","outDir","start","succeed","err","fail","parentDir","base","tarball","entries","pipe","manifest","message","Error","String","warn","applicationId","id","isApp","version","log","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,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,IAAI,QAAO,SAAQ;AAE3B,SAAQC,gBAAgB,QAAO,qCAAoC;AACnE,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,kBAAkB,QAAO,8BAA6B;AAC9D,SAAQC,sBAAsB,QAAO,uCAAsC;AAC3E,SAAQC,qBAAqB,QAAO,sCAAqC;AACzE,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,SAAS,EAAEC,OAAO,EAAC,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,MAAM,EAAC8C,OAAO,EAAE,GAAGW,cAAa,GAAG9B;YACnCR,OAAOQ,KAAK,CAACmB,SAAS;gBAAC,GAAGW,YAAY;gBAAE7B,MAAM;YAAC;YAC/C;QACF;QAEAf,YAAY,+BAA+Bc;QAC3CR,OAAOQ,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 {spinner} from '@sanity/cli-core/ux'\nimport {pack} from 'tar-fs'\n\nimport {createDeployment} from '../../services/userApplications.js'\nimport {getAppId} from '../../util/appId.js'\nimport {NO_ORGANIZATION_ID} from '../../util/errorMessages.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, sourceDir, workDir} = options\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 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({flags, workDir})\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n deployDebug('Error extracting app manifest', err)\n output.warn(`Error extracting app manifest: ${message}`)\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","getAppId","NO_ORGANIZATION_ID","getLocalPackageVersion","buildApp","shouldAutoUpdate","extractAppManifest","checkDir","createUserApplicationForApp","deployDebug","findUserApplicationForApp","deployApp","options","cliConfig","flags","output","sourceDir","workDir","organizationId","app","appId","isAutoUpdating","installedSdkVersion","error","exit","spin","userApplication","shouldBuild","build","autoUpdatesEnabled","calledFromDeploy","outDir","start","succeed","err","fail","parentDir","base","tarball","entries","pipe","manifest","message","Error","String","warn","applicationId","id","isApp","version","log","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,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,IAAI,QAAO,SAAQ;AAE3B,SAAQC,gBAAgB,QAAO,qCAAoC;AACnE,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,kBAAkB,QAAO,8BAA6B;AAC9D,SAAQC,sBAAsB,QAAO,uCAAsC;AAC3E,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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QACA,8GAA8G;QAC9G,IAAID,iBAAiB1B,UAAU;YAC7B,MAAM,EAAC6C,OAAO,EAAE,GAAGW,cAAa,GAAG9B;YACnCR,OAAOQ,KAAK,CAACmB,SAAS;gBAAC,GAAGW,YAAY;gBAAE7B,MAAM;YAAC;YAC/C;QACF;QAEAf,YAAY,+BAA+Bc;QAC3CR,OAAOQ,KAAK,CAAC,CAAC,6BAA6B,EAAEA,OAAO,EAAE;YAACC,MAAM;QAAC;IAChE;AACF"}
@@ -60,6 +60,7 @@ export async function deployStudio(options) {
60
60
  deployDebug(`Building studio`);
61
61
  await buildStudio({
62
62
  autoUpdatesEnabled: isAutoUpdating,
63
+ calledFromDeploy: true,
63
64
  cliConfig,
64
65
  flags,
65
66
  outDir: sourceDir,
@@ -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} 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} 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 {checkDir} from './checkDir.js'\nimport {createStudioUserApplication} from './createStudioUserApplication.js'\nimport {deployDebug} from './deployDebug.js'\nimport {findUserApplicationForStudio} from './findUserApplicationForStudio.js'\nimport {type DeployAppOptions} from './types.js'\n\nexport async function deployStudio(options: DeployAppOptions) {\n const {cliConfig, flags, output, sourceDir, workDir} = options\n\n const appHost = cliConfig.studioHost\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 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 })\n\n if (!userApplication) {\n // otherwise, prompt the user for a hostname\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 part you want to use.')\n\n userApplication = await createStudioUserApplication(projectId)\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\n const shouldBuild = flags.build\n if (shouldBuild) {\n deployDebug(`Building studio`)\n await buildStudio({\n autoUpdatesEnabled: isAutoUpdating,\n cliConfig,\n flags,\n outDir: sourceDir,\n output,\n workDir,\n })\n }\n\n // TODO: Implement schema deployment\n // await deploySchemasAction(\n // {\n // 'extract-manifest': shouldBuild,\n // 'manifest-dir': `${sourceDir}/static`,\n // 'schema-required': flags['schema-required'],\n // 'verbose': flags.verbose,\n // },\n // {...context, manifestExtractor: createManifestExtractor(context)},\n // )\n\n // Ensure that the directory exists, is a directory and seems to have valid content\n 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 const tarball = pack(parentDir, {entries: [base]}).pipe(createGzip())\n\n spin = spinner('Deploying to sanity.studio').start()\n\n const {location} = await createDeployment({\n applicationId: userApplication.id,\n isApp: false,\n isAutoUpdating,\n projectId,\n tarball,\n version: installedSanityVersion,\n })\n\n spin.succeed()\n\n // And let the user know we're done\n output.log(`\\nSuccess! Studio deployed to ${styleText('cyan', location || 'unknown URL')}`)\n\n if (!appId) {\n output.log(`\\nAdd ${styleText('cyan', `deployment: { appId: '${userApplication.id}' }`)}`)\n output.log(`to sanity.cli.js or sanity.cli.ts`)\n output.log(`to avoid prompting on next deploy.`)\n }\n } catch (error) {\n // if the error is a CLIError, we can just output the message and exit\n if (error instanceof CLIError) {\n output.error(error.message, {exit: 1})\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"],"names":["basename","dirname","styleText","createGzip","CLIError","spinner","pack","createDeployment","getAppId","NO_PROJECT_ID","getLocalPackageVersion","buildStudio","shouldAutoUpdate","checkDir","createStudioUserApplication","deployDebug","findUserApplicationForStudio","deployStudio","options","cliConfig","flags","output","sourceDir","workDir","appHost","studioHost","appId","projectId","api","installedSanityVersion","isAutoUpdating","error","exit","spin","userApplication","log","shouldBuild","build","autoUpdatesEnabled","outDir","start","succeed","err","fail","parentDir","base","tarball","entries","pipe","location","applicationId","id","isApp","version","message"],"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,OAAO,QAAO,sBAAqB;AAC3C,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,QAAQ,QAAO,gBAAe;AACtC,SAAQC,2BAA2B,QAAO,mCAAkC;AAC5E,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAAQC,4BAA4B,QAAO,oCAAmC;AAG9E,OAAO,eAAeC,aAAaC,OAAyB;IAC1D,MAAM,EAACC,S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QACd,EAAE,OAAOC,KAAK;YACZT,KAAKU,IAAI;YACT5B,YAAY,4BAA4B2B;YACxCrB,OAAOU,KAAK,CAAC,4BAA4B;gBAACC,MAAM;YAAC;QACnD;QAEA,0CAA0C;QAC1C,MAAMY,YAAY3C,QAAQqB;QAC1B,MAAMuB,OAAO7C,SAASsB;QACtB,MAAMwB,UAAUxC,KAAKsC,WAAW;YAACG,SAAS;gBAACF;aAAK;QAAA,GAAGG,IAAI,CAAC7C;QAExD8B,OAAO5B,QAAQ,8BAA8BmC,KAAK;QAElD,MAAM,EAACS,QAAQ,EAAC,GAAG,MAAM1C,iBAAiB;YACxC2C,eAAehB,gBAAgBiB,EAAE;YACjCC,OAAO;YACPtB;YACAH;YACAmB;YACAO,SAASxB;QACX;QAEAI,KAAKQ,OAAO;QAEZ,mCAAmC;QACnCpB,OAAOc,GAAG,CAAC,CAAC,8BAA8B,EAAEjC,UAAU,QAAQ+C,YAAY,gBAAgB;QAE1F,IAAI,CAACvB,OAAO;YACVL,OAAOc,GAAG,CAAC,CAAC,MAAM,EAAEjC,UAAU,QAAQ,CAAC,sBAAsB,EAAEgC,gBAAgBiB,EAAE,CAAC,GAAG,CAAC,GAAG;YACzF9B,OAAOc,GAAG,CAAC,CAAC,iCAAiC,CAAC;YAC9Cd,OAAOc,GAAG,CAAC,CAAC,kCAAkC,CAAC;QACjD;IACF,EAAE,OAAOJ,OAAO;QACd,sEAAsE;QACtE,IAAIA,iBAAiB3B,UAAU;YAC7BiB,OAAOU,KAAK,CAACA,MAAMuB,OAAO,EAAE;gBAACtB,MAAM;YAAC;YACpC;QACF;QAEAC,KAAKU,IAAI;QACT5B,YAAY,0BAA0BgB;QACtCV,OAAOU,KAAK,CAAC,CAAC,wBAAwB,EAAEA,OAAO,EAAE;YAACC,MAAM;QAAC;IAC3D;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/deploy/deployStudio.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} 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 {checkDir} from './checkDir.js'\nimport {createStudioUserApplication} from './createStudioUserApplication.js'\nimport {deployDebug} from './deployDebug.js'\nimport {findUserApplicationForStudio} from './findUserApplicationForStudio.js'\nimport {type DeployAppOptions} from './types.js'\n\nexport async function deployStudio(options: DeployAppOptions) {\n const {cliConfig, flags, output, sourceDir, workDir} = options\n\n const appHost = cliConfig.studioHost\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 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 })\n\n if (!userApplication) {\n // otherwise, prompt the user for a hostname\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 part you want to use.')\n\n userApplication = await createStudioUserApplication(projectId)\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\n const shouldBuild = flags.build\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 // TODO: Implement schema deployment\n // await deploySchemasAction(\n // {\n // 'extract-manifest': shouldBuild,\n // 'manifest-dir': `${sourceDir}/static`,\n // 'schema-required': flags['schema-required'],\n // 'verbose': flags.verbose,\n // },\n // {...context, manifestExtractor: createManifestExtractor(context)},\n // )\n\n // Ensure that the directory exists, is a directory and seems to have valid content\n 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 const tarball = pack(parentDir, {entries: [base]}).pipe(createGzip())\n\n spin = spinner('Deploying to sanity.studio').start()\n\n const {location} = await createDeployment({\n applicationId: userApplication.id,\n isApp: false,\n isAutoUpdating,\n projectId,\n tarball,\n version: installedSanityVersion,\n })\n\n spin.succeed()\n\n // And let the user know we're done\n output.log(`\\nSuccess! Studio deployed to ${styleText('cyan', location || 'unknown URL')}`)\n\n if (!appId) {\n output.log(`\\nAdd ${styleText('cyan', `deployment: { appId: '${userApplication.id}' }`)}`)\n output.log(`to sanity.cli.js or sanity.cli.ts`)\n output.log(`to avoid prompting on next deploy.`)\n }\n } catch (error) {\n // if the error is a CLIError, we can just output the message and exit\n if (error instanceof CLIError) {\n output.error(error.message, {exit: 1})\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"],"names":["basename","dirname","styleText","createGzip","CLIError","spinner","pack","createDeployment","getAppId","NO_PROJECT_ID","getLocalPackageVersion","buildStudio","shouldAutoUpdate","checkDir","createStudioUserApplication","deployDebug","findUserApplicationForStudio","deployStudio","options","cliConfig","flags","output","sourceDir","workDir","appHost","studioHost","appId","projectId","api","installedSanityVersion","isAutoUpdating","error","exit","spin","userApplication","log","shouldBuild","build","autoUpdatesEnabled","calledFromDeploy","outDir","start","succeed","err","fail","parentDir","base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,8BAA8B,EAAEjC,UAAU,QAAQgD,YAAY,gBAAgB;QAE1F,IAAI,CAACxB,OAAO;YACVL,OAAOc,GAAG,CAAC,CAAC,MAAM,EAAEjC,UAAU,QAAQ,CAAC,sBAAsB,EAAEgC,gBAAgBkB,EAAE,CAAC,GAAG,CAAC,GAAG;YACzF/B,OAAOc,GAAG,CAAC,CAAC,iCAAiC,CAAC;YAC9Cd,OAAOc,GAAG,CAAC,CAAC,kCAAkC,CAAC;QACjD;IACF,EAAE,OAAOJ,OAAO;QACd,sEAAsE;QACtE,IAAIA,iBAAiB3B,UAAU;YAC7BiB,OAAOU,KAAK,CAACA,MAAMwB,OAAO,EAAE;gBAACvB,MAAM;YAAC;YACpC;QACF;QAEAC,KAAKW,IAAI;QACT7B,YAAY,0BAA0BgB;QACtCV,OAAOU,KAAK,CAAC,CAAC,wBAAwB,EAAEA,OAAO,EAAE;YAACC,MAAM;QAAC;IAC3D;AACF"}
@@ -1,4 +1,5 @@
1
1
  import path from 'node:path';
2
+ import { getSanityEnvVar } from '@sanity/cli-core';
2
3
  import { spinner } from '@sanity/cli-core/ux';
3
4
  import { getSharedServerConfig } from '../../util/getSharedServerConfig.js';
4
5
  export function getDevServerConfig({ cliConfig, flags, output, workDir }) {
@@ -12,10 +13,12 @@ export function getDevServerConfig({ cliConfig, flags, output, workDir }) {
12
13
  workDir
13
14
  });
14
15
  configSpinner.succeed();
16
+ const isApp = cliConfig && 'app' in cliConfig;
15
17
  const env = process.env;
16
18
  const reactStrictMode = env.SANITY_STUDIO_REACT_STRICT_MODE ? env.SANITY_STUDIO_REACT_STRICT_MODE === 'true' : Boolean(cliConfig?.reactStrictMode);
17
- if (env.SANITY_STUDIO_BASEPATH && cliConfig?.project?.basePath) {
18
- output.warn(`Overriding configured base path (${cliConfig.project.basePath}) with value from environment variable (${env.SANITY_STUDIO_BASEPATH})`);
19
+ const envBasePath = getSanityEnvVar('BASEPATH', isApp ?? false);
20
+ if (envBasePath && cliConfig?.project?.basePath) {
21
+ output.warn(`Overriding configured base path (${cliConfig.project.basePath}) with value from environment variable (${envBasePath})`);
19
22
  }
20
23
  return {
21
24
  ...baseConfig,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/dev/getDevServerConfig.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {type CliConfig, type Output} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\n\nimport {type DevServerOptions} from '../../server/devServer.js'\nimport {getSharedServerConfig} from '../../util/getSharedServerConfig.js'\nimport {type DevFlags} from './types.js'\n\nexport function getDevServerConfig({\n cliConfig,\n flags,\n output,\n workDir,\n}: {\n cliConfig?: CliConfig\n flags: DevFlags\n output: Output\n workDir: string\n}): Omit<DevServerOptions, 'spinner'> {\n const configSpinner = spinner('Checking configuration files...')\n\n const baseConfig = getSharedServerConfig({\n cliConfig,\n flags: {\n host: flags.host,\n port: flags.port,\n },\n workDir,\n })\n\n configSpinner.succeed()\n\n const env = process.env\n const reactStrictMode = env.SANITY_STUDIO_REACT_STRICT_MODE\n ? env.SANITY_STUDIO_REACT_STRICT_MODE === 'true'\n : Boolean(cliConfig?.reactStrictMode)\n\n if (env.SANITY_STUDIO_BASEPATH && cliConfig?.project?.basePath) {\n output.warn(\n `Overriding configured base path (${cliConfig.project.basePath}) with value from environment variable (${env.SANITY_STUDIO_BASEPATH})`,\n )\n }\n\n return {\n ...baseConfig,\n reactCompiler: cliConfig && 'reactCompiler' in cliConfig ? cliConfig.reactCompiler : undefined,\n reactStrictMode,\n staticPath: path.join(workDir, 'static'),\n }\n}\n"],"names":["path","spinner","getSharedServerConfig","getDevServerConfig","cliConfig","flags","output","workDir","configSpinner","baseConfig","host","port","succeed","env","process","reactStrictMode","SANITY_STUDIO_REACT_STRICT_MODE","Boolean","SANITY_STUDIO_BASEPATH","project","basePath","warn","reactCompiler","undefined","staticPath","join"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAG5B,SAAQC,OAAO,QAAO,sBAAqB;AAG3C,SAAQC,qBAAqB,QAAO,sCAAqC;AAGzE,OAAO,SAASC,mBAAmB,EACjCC,SAAS,EACTC,KAAK,EACLC,MAAM,EACNC,OAAO,EAMR;IACC,MAAMC,gBAAgBP,QAAQ;IAE9B,MAAMQ,aAAaP,sBAAsB;QACvCE;QACAC,OAAO;YACLK,MAAML,MAAMK,IAAI;YAChBC,MAAMN,MAAMM,IAAI;QAClB;QACAJ;IACF;IAEAC,cAAcI,OAAO;IAErB,MAAMC,MAAMC,QAAQD,GAAG;IACvB,MAAME,kBAAkBF,IAAIG,+BAA+B,GACvDH,IAAIG,+BAA+B,KAAK,SACxCC,QAAQb,WAAWW;IAEvB,IAAIF,IAAIK,sBAAsB,IAAId,WAAWe,SAASC,UAAU;QAC9Dd,OAAOe,IAAI,CACT,CAAC,iCAAiC,EAAEjB,UAAUe,OAAO,CAACC,QAAQ,CAAC,wCAAwC,EAAEP,IAAIK,sBAAsB,CAAC,CAAC,CAAC;IAE1I;IAEA,OAAO;QACL,GAAGT,UAAU;QACba,eAAelB,aAAa,mBAAmBA,YAAYA,UAAUkB,aAAa,GAAGC;QACrFR;QACAS,YAAYxB,KAAKyB,IAAI,CAAClB,SAAS;IACjC;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/dev/getDevServerConfig.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {type CliConfig, getSanityEnvVar, type Output} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\n\nimport {type DevServerOptions} from '../../server/devServer.js'\nimport {getSharedServerConfig} from '../../util/getSharedServerConfig.js'\nimport {type DevFlags} from './types.js'\n\nexport function getDevServerConfig({\n cliConfig,\n flags,\n output,\n workDir,\n}: {\n cliConfig?: CliConfig\n flags: DevFlags\n output: Output\n workDir: string\n}): Omit<DevServerOptions, 'spinner'> {\n const configSpinner = spinner('Checking configuration files...')\n\n const baseConfig = getSharedServerConfig({\n cliConfig,\n flags: {\n host: flags.host,\n port: flags.port,\n },\n workDir,\n })\n\n configSpinner.succeed()\n\n const isApp = cliConfig && 'app' in cliConfig\n const env = process.env\n const reactStrictMode = env.SANITY_STUDIO_REACT_STRICT_MODE\n ? env.SANITY_STUDIO_REACT_STRICT_MODE === 'true'\n : Boolean(cliConfig?.reactStrictMode)\n\n const envBasePath = getSanityEnvVar('BASEPATH', isApp ?? false)\n if (envBasePath && cliConfig?.project?.basePath) {\n output.warn(\n `Overriding configured base path (${cliConfig.project.basePath}) with value from environment variable (${envBasePath})`,\n )\n }\n\n return {\n ...baseConfig,\n reactCompiler: cliConfig && 'reactCompiler' in cliConfig ? cliConfig.reactCompiler : undefined,\n reactStrictMode,\n staticPath: path.join(workDir, 'static'),\n }\n}\n"],"names":["path","getSanityEnvVar","spinner","getSharedServerConfig","getDevServerConfig","cliConfig","flags","output","workDir","configSpinner","baseConfig","host","port","succeed","isApp","env","process","reactStrictMode","SANITY_STUDIO_REACT_STRICT_MODE","Boolean","envBasePath","project","basePath","warn","reactCompiler","undefined","staticPath","join"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B,SAAwBC,eAAe,QAAoB,mBAAkB;AAC7E,SAAQC,OAAO,QAAO,sBAAqB;AAG3C,SAAQC,qBAAqB,QAAO,sCAAqC;AAGzE,OAAO,SAASC,mBAAmB,EACjCC,SAAS,EACTC,KAAK,EACLC,MAAM,EACNC,OAAO,EAMR;IACC,MAAMC,gBAAgBP,QAAQ;IAE9B,MAAMQ,aAAaP,sBAAsB;QACvCE;QACAC,OAAO;YACLK,MAAML,MAAMK,IAAI;YAChBC,MAAMN,MAAMM,IAAI;QAClB;QACAJ;IACF;IAEAC,cAAcI,OAAO;IAErB,MAAMC,QAAQT,aAAa,SAASA;IACpC,MAAMU,MAAMC,QAAQD,GAAG;IACvB,MAAME,kBAAkBF,IAAIG,+BAA+B,GACvDH,IAAIG,+BAA+B,KAAK,SACxCC,QAAQd,WAAWY;IAEvB,MAAMG,cAAcnB,gBAAgB,YAAYa,SAAS;IACzD,IAAIM,eAAef,WAAWgB,SAASC,UAAU;QAC/Cf,OAAOgB,IAAI,CACT,CAAC,iCAAiC,EAAElB,UAAUgB,OAAO,CAACC,QAAQ,CAAC,wCAAwC,EAAEF,YAAY,CAAC,CAAC;IAE3H;IAEA,OAAO;QACL,GAAGV,UAAU;QACbc,eAAenB,aAAa,mBAAmBA,YAAYA,UAAUmB,aAAa,GAAGC;QACrFR;QACAS,YAAY1B,KAAK2B,IAAI,CAACnB,SAAS;IACjC;AACF"}
@@ -65,9 +65,14 @@ export async function startStudioDevServer(options) {
65
65
  projectId
66
66
  });
67
67
  }
68
+ if (result?.unresolvedPrerelease.length) {
69
+ for (const mod of result.unresolvedPrerelease){
70
+ output.warn(`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.`);
71
+ }
72
+ }
68
73
  // mismatch between local and auto-updating dependencies
69
- if (result?.length) {
70
- const message = `The following local package versions are different from the versions currently served at runtime.\n` + `When using auto updates, we recommend that you run with the same versions locally as will be used when deploying.\n\n` + `${result.map((mod)=>` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\n')}\n\n`;
74
+ if (result?.mismatched.length) {
75
+ const message = `The following local package versions are different from the versions currently served at runtime.\n` + `When using auto updates, we recommend that you run with the same versions locally as will be used when deploying.\n\n` + `${result.mismatched.map((mod)=>` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\n')}\n\n`;
71
76
  if (isInteractive()) {
72
77
  const shouldUpgrade = await confirm({
73
78
  default: true,
@@ -78,7 +83,7 @@ export async function startStudioDevServer(options) {
78
83
  packageManager: (await getPackageManagerChoice(workDir, {
79
84
  interactive: false
80
85
  })).chosen,
81
- packages: result.map((res)=>[
86
+ packages: result.mismatched.map((res)=>[
82
87
  res.pkg,
83
88
  res.remote
84
89
  ])