@sanity/cli 6.4.0 → 6.5.0

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 (99) hide show
  1. package/README.md +14 -8
  2. package/dist/actions/build/buildApp.js +12 -4
  3. package/dist/actions/build/buildApp.js.map +1 -1
  4. package/dist/actions/build/buildStaticFiles.js +3 -1
  5. package/dist/actions/build/buildStaticFiles.js.map +1 -1
  6. package/dist/actions/build/buildStudio.js +29 -7
  7. package/dist/actions/build/buildStudio.js.map +1 -1
  8. package/dist/actions/build/buildVendorDependencies.js +7 -7
  9. package/dist/actions/build/buildVendorDependencies.js.map +1 -1
  10. package/dist/actions/build/checkRequiredDependencies.js +4 -4
  11. package/dist/actions/build/checkRequiredDependencies.js.map +1 -1
  12. package/dist/actions/build/checkStudioDependencyVersions.js +9 -9
  13. package/dist/actions/build/checkStudioDependencyVersions.js.map +1 -1
  14. package/dist/actions/build/getAutoUpdatesImportMap.js +9 -0
  15. package/dist/actions/build/getAutoUpdatesImportMap.js.map +1 -1
  16. package/dist/actions/build/getViteConfig.js +2 -1
  17. package/dist/actions/build/getViteConfig.js.map +1 -1
  18. package/dist/actions/build/renderDocument.js.map +1 -1
  19. package/dist/actions/build/renderDocumentWorker/addTimestampImportMapScriptToHtml.js +34 -14
  20. package/dist/actions/build/renderDocumentWorker/addTimestampImportMapScriptToHtml.js.map +1 -1
  21. package/dist/actions/build/renderDocumentWorker/getDocumentHtml.js +2 -2
  22. package/dist/actions/build/renderDocumentWorker/getDocumentHtml.js.map +1 -1
  23. package/dist/actions/build/renderDocumentWorker/renderDocumentWorker.js +2 -2
  24. package/dist/actions/build/renderDocumentWorker/renderDocumentWorker.js.map +1 -1
  25. package/dist/actions/codemods/reactIconsV3.js +2 -2
  26. package/dist/actions/codemods/reactIconsV3.js.map +1 -1
  27. package/dist/actions/dev/startStudioDevServer.js +2 -2
  28. package/dist/actions/dev/startStudioDevServer.js.map +1 -1
  29. package/dist/actions/doctor/types.js.map +1 -1
  30. package/dist/actions/graphql/resolveGraphQLApisFromWorkspaces.js.map +1 -1
  31. package/dist/actions/init/bootstrapTemplate.js.map +1 -1
  32. package/dist/actions/init/checkNextJsReactCompatibility.js +3 -3
  33. package/dist/actions/init/checkNextJsReactCompatibility.js.map +1 -1
  34. package/dist/actions/init/initAction.js +287 -0
  35. package/dist/actions/init/initAction.js.map +1 -0
  36. package/dist/actions/init/initApp.js +7 -16
  37. package/dist/actions/init/initApp.js.map +1 -1
  38. package/dist/actions/init/initError.js +10 -0
  39. package/dist/actions/init/initError.js.map +1 -0
  40. package/dist/actions/init/initHelpers.js +3 -12
  41. package/dist/actions/init/initHelpers.js.map +1 -1
  42. package/dist/actions/init/initNextJs.js +17 -20
  43. package/dist/actions/init/initNextJs.js.map +1 -1
  44. package/dist/actions/init/initStudio.js +11 -20
  45. package/dist/actions/init/initStudio.js.map +1 -1
  46. package/dist/actions/init/plan/getPlan.js +15 -0
  47. package/dist/actions/init/plan/getPlan.js.map +1 -0
  48. package/dist/actions/init/plan/verifyCoupon.js +35 -0
  49. package/dist/actions/init/plan/verifyCoupon.js.map +1 -0
  50. package/dist/actions/init/plan/verifyPlan.js +34 -0
  51. package/dist/actions/init/plan/verifyPlan.js.map +1 -0
  52. package/dist/actions/init/project/createProjectFromName.js +44 -0
  53. package/dist/actions/init/project/createProjectFromName.js.map +1 -0
  54. package/dist/actions/init/project/getOrCreateDataset.js +126 -0
  55. package/dist/actions/init/project/getOrCreateDataset.js.map +1 -0
  56. package/dist/actions/init/project/getOrCreateProject.js +128 -0
  57. package/dist/actions/init/project/getOrCreateProject.js.map +1 -0
  58. package/dist/actions/init/project/getProjectDetails.js +87 -0
  59. package/dist/actions/init/project/getProjectDetails.js.map +1 -0
  60. package/dist/actions/init/project/getProjectOutputPath.js +17 -0
  61. package/dist/actions/init/project/getProjectOutputPath.js.map +1 -0
  62. package/dist/actions/init/project/promptForAppTemplateSetup.js +112 -0
  63. package/dist/actions/init/project/promptForAppTemplateSetup.js.map +1 -0
  64. package/dist/actions/init/project/promptForProjectCreation.js +40 -0
  65. package/dist/actions/init/project/promptForProjectCreation.js.map +1 -0
  66. package/dist/actions/init/project/promptUserForNewOrganization.js +12 -0
  67. package/dist/actions/init/project/promptUserForNewOrganization.js.map +1 -0
  68. package/dist/actions/init/project/promptUserForOrganization.js +38 -0
  69. package/dist/actions/init/project/promptUserForOrganization.js.map +1 -0
  70. package/dist/actions/init/scaffoldTemplate.js +23 -29
  71. package/dist/actions/init/scaffoldTemplate.js.map +1 -1
  72. package/dist/actions/init/types.js +47 -1
  73. package/dist/actions/init/types.js.map +1 -1
  74. package/dist/actions/manifest/types.js +0 -1
  75. package/dist/actions/manifest/types.js.map +1 -1
  76. package/dist/actions/versions/buildPackageArray.js +2 -2
  77. package/dist/actions/versions/buildPackageArray.js.map +1 -1
  78. package/dist/actions/versions/findSanityModulesVersions.js +3 -3
  79. package/dist/actions/versions/findSanityModulesVersions.js.map +1 -1
  80. package/dist/commands/datasets/copy.js.map +1 -1
  81. package/dist/commands/init.js +11 -911
  82. package/dist/commands/init.js.map +1 -1
  83. package/dist/server/vite/plugin-sanity-build-entries.js +2 -1
  84. package/dist/server/vite/plugin-sanity-build-entries.js.map +1 -1
  85. package/dist/services/datasets.js.map +1 -1
  86. package/dist/telemetry/init.telemetry.js.map +1 -1
  87. package/dist/util/compareDependencyVersions.js +4 -4
  88. package/dist/util/compareDependencyVersions.js.map +1 -1
  89. package/dist/util/createExpiringConfig.js +1 -1
  90. package/dist/util/createExpiringConfig.js.map +1 -1
  91. package/dist/util/packageManager/installationInfo/analyzeIssues.js +7 -7
  92. package/dist/util/packageManager/installationInfo/analyzeIssues.js.map +1 -1
  93. package/dist/util/packageManager/installationInfo/types.js.map +1 -1
  94. package/dist/util/packageManager/packageManagerChoice.js +2 -2
  95. package/dist/util/packageManager/packageManagerChoice.js.map +1 -1
  96. package/dist/util/packageManager/preferredPm.js +106 -0
  97. package/dist/util/packageManager/preferredPm.js.map +1 -0
  98. package/oclif.manifest.json +526 -526
  99. package/package.json +23 -22
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/dev/startStudioDevServer.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {isInteractive} from '@sanity/cli-core'\nimport {confirm, logSymbols, spinner} from '@sanity/cli-core/ux'\nimport semver from 'semver'\n\nimport {startDevServer} from '../../server/devServer.js'\nimport {gracefulServerDeath} from '../../server/gracefulServerDeath.js'\nimport {getProjectById} from '../../services/projects.js'\nimport {getAppId} from '../../util/appId.js'\nimport {compareDependencyVersions} from '../../util/compareDependencyVersions.js'\nimport {getLocalPackageVersion} from '../../util/getLocalPackageVersion.js'\nimport {getPackageManagerChoice} from '../../util/packageManager/packageManagerChoice.js'\nimport {upgradePackages} from '../../util/packageManager/upgradePackages.js'\nimport {checkRequiredDependencies} from '../build/checkRequiredDependencies.js'\nimport {checkStudioDependencyVersions} from '../build/checkStudioDependencyVersions.js'\nimport {shouldAutoUpdate} from '../build/shouldAutoUpdate.js'\nimport {devDebug} from './devDebug.js'\nimport {getDashboardAppURL} from './getDashboardAppUrl.js'\nimport {getDevServerConfig} from './getDevServerConfig.js'\nimport {type DevActionOptions} from './types.js'\n\nexport async function startStudioDevServer(\n options: DevActionOptions,\n): Promise<{close?: () => Promise<void>}> {\n const {cliConfig, flags, output, workDir} = options\n const projectId = cliConfig?.api?.projectId\n let organizationId: string | undefined\n\n const loadInDashboard = flags['load-in-dashboard']\n\n // Check studio dependency versions\n await checkStudioDependencyVersions(workDir, output)\n\n const {installedSanityVersion} = await checkRequiredDependencies(options)\n\n // Check if auto-updates are enabled\n const autoUpdatesEnabled = shouldAutoUpdate({cliConfig, flags, output})\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSanityVersion = semver.parse(installedSanityVersion)?.version\n if (!cleanSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n\n const sanityDependencies = [\n {name: 'sanity', version: cleanSanityVersion},\n {name: '@sanity/vision', version: cleanSanityVersion},\n ]\n\n output.log(`${logSymbols.info} Running with auto-updates enabled`)\n\n // Check local versions against deployed versions\n let result: Awaited<ReturnType<typeof compareDependencyVersions>> | undefined\n\n const appId = getAppId(cliConfig)\n\n try {\n result = await compareDependencyVersions(sanityDependencies, workDir, {appId})\n } catch (err) {\n output.warn(`Failed to compare local versions against auto-updating versions: ${err}`)\n }\n\n if (result?.unresolvedPrerelease.length) {\n for (const mod of result.unresolvedPrerelease) {\n output.warn(\n `Your local version of ${mod.pkg} (${mod.version}) is a prerelease not available on the auto-updates CDN. The locally installed version will be used.`,\n )\n }\n }\n\n // mismatch between local and auto-updating dependencies\n if (result?.mismatched.length) {\n const message =\n `The following local package versions are different from the versions currently served at runtime.\\n` +\n `When using auto updates, we recommend that you run with the same versions locally as will be used when deploying.\\n\\n` +\n `${result.mismatched.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')}\\n\\n`\n\n if (isInteractive()) {\n const shouldUpgrade = await confirm({\n default: true,\n message: styleText('yellow', `${message}Do you want to upgrade local versions?`),\n })\n if (shouldUpgrade) {\n await upgradePackages(\n {\n packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,\n packages: result.mismatched.map((res) => [res.pkg, res.remote]),\n },\n {output, workDir},\n )\n }\n } else {\n // In this case we warn the user but we don't ask them if they want to upgrade because it's not interactive.\n output.log(styleText('yellow', message))\n }\n }\n }\n\n if (cliConfig?.schemaExtraction?.enabled) {\n output.log(`${logSymbols.info} Running dev server with schema extraction enabled`)\n }\n\n const config = getDevServerConfig({cliConfig, flags, output, workDir})\n\n if (loadInDashboard) {\n if (!projectId) {\n output.error('Project Id is required to load in dashboard', {exit: 1})\n }\n\n try {\n const project = await getProjectById(projectId!)\n organizationId = project.organizationId!\n } catch (error) {\n devDebug('Error getting organization id from project id', error)\n output.error('Failed to get organization id from project id', {exit: 1})\n }\n }\n\n try {\n const startTime = Date.now()\n const spin = spinner('Starting dev server').start()\n const {close, server} = await startDevServer(config)\n\n const {info: loggerInfo} = server.config.logger\n const {port} = server.config.server\n const httpHost = config.httpHost || 'localhost'\n\n if (loadInDashboard) {\n spin.succeed()\n\n output.log(`Dev server started on port ${port}`)\n output.log(`View your studio in the Sanity dashboard here:`)\n output.log(\n styleText(\n ['blue', 'underline'],\n await getDashboardAppURL({\n httpHost,\n httpPort: port,\n organizationId: organizationId!,\n }),\n ),\n )\n } else {\n const startupDuration = Date.now() - startTime\n const url = `http://${httpHost || 'localhost'}:${port}${config.basePath}`\n const appType = 'Sanity Studio'\n\n const viteVersion = await getLocalPackageVersion('vite', import.meta.url)\n spin.succeed()\n\n loggerInfo(\n `${appType} ` +\n `using ${styleText('cyan', `vite@${viteVersion}`)} ` +\n `ready in ${styleText('cyan', `${Math.ceil(startupDuration)}ms`)} ` +\n `and running at ${styleText('cyan', url)}`,\n )\n }\n\n return {close}\n } catch (err) {\n devDebug('Error starting studio dev server', err)\n throw gracefulServerDeath('dev', config.httpHost, config.httpPort, err)\n }\n}\n"],"names":["styleText","isInteractive","confirm","logSymbols","spinner","semver","startDevServer","gracefulServerDeath","getProjectById","getAppId","compareDependencyVersions","getLocalPackageVersion","getPackageManagerChoice","upgradePackages","checkRequiredDependencies","checkStudioDependencyVersions","shouldAutoUpdate","devDebug","getDashboardAppURL","getDevServerConfig","startStudioDevServer","options","cliConfig","flags","output","workDir","projectId","api","organizationId","loadInDashboard","installedSanityVersion","autoUpdatesEnabled","cleanSanityVersion","parse","version","Error","sanityDependencies","name","log","info","result","appId","err","warn","unresolvedPrerelease","length","mod","pkg","mismatched","message","map","installed","remote","join","shouldUpgrade","default","packageManager","interactive","chosen","packages","res","schemaExtraction","enabled","config","error","exit","project","startTime","Date","now","spin","start","close","server","loggerInfo","logger","port","httpHost","succeed","httpPort","startupDuration","url","basePath","appType","viteVersion","Math","ceil"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAA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MAAMkB,mBAAmB;gBACvB2D;gBACAE,UAAUH;gBACVhD,gBAAgBA;YAClB;QAGN,OAAO;YACL,MAAMoD,kBAAkBZ,KAAKC,GAAG,KAAKF;YACrC,MAAMc,MAAM,CAAC,OAAO,EAAEJ,YAAY,YAAY,CAAC,EAAED,OAAOb,OAAOmB,QAAQ,EAAE;YACzE,MAAMC,UAAU;YAEhB,MAAMC,cAAc,MAAMzE,uBAAuB,QAAQ,YAAYsE,GAAG;YACxEX,KAAKQ,OAAO;YAEZJ,WACE,GAAGS,QAAQ,CAAC,CAAC,GACX,CAAC,MAAM,EAAEnF,UAAU,QAAQ,CAAC,KAAK,EAAEoF,aAAa,EAAE,CAAC,CAAC,GACpD,CAAC,SAAS,EAAEpF,UAAU,QAAQ,GAAGqF,KAAKC,IAAI,CAACN,iBAAiB,EAAE,CAAC,EAAE,CAAC,CAAC,GACnE,CAAC,eAAe,EAAEhF,UAAU,QAAQiF,MAAM;QAEhD;QAEA,OAAO;YAACT;QAAK;IACf,EAAE,OAAO9B,KAAK;QACZzB,SAAS,oCAAoCyB;QAC7C,MAAMnC,oBAAoB,OAAOwD,OAAOc,QAAQ,EAAEd,OAAOgB,QAAQ,EAAErC;IACrE;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/dev/startStudioDevServer.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {isInteractive} from '@sanity/cli-core'\nimport {confirm, logSymbols, spinner} from '@sanity/cli-core/ux'\nimport {parse as semverParse} from 'semver'\n\nimport {startDevServer} from '../../server/devServer.js'\nimport {gracefulServerDeath} from '../../server/gracefulServerDeath.js'\nimport {getProjectById} from '../../services/projects.js'\nimport {getAppId} from '../../util/appId.js'\nimport {compareDependencyVersions} from '../../util/compareDependencyVersions.js'\nimport {getLocalPackageVersion} from '../../util/getLocalPackageVersion.js'\nimport {getPackageManagerChoice} from '../../util/packageManager/packageManagerChoice.js'\nimport {upgradePackages} from '../../util/packageManager/upgradePackages.js'\nimport {checkRequiredDependencies} from '../build/checkRequiredDependencies.js'\nimport {checkStudioDependencyVersions} from '../build/checkStudioDependencyVersions.js'\nimport {shouldAutoUpdate} from '../build/shouldAutoUpdate.js'\nimport {devDebug} from './devDebug.js'\nimport {getDashboardAppURL} from './getDashboardAppUrl.js'\nimport {getDevServerConfig} from './getDevServerConfig.js'\nimport {type DevActionOptions} from './types.js'\n\nexport async function startStudioDevServer(\n options: DevActionOptions,\n): Promise<{close?: () => Promise<void>}> {\n const {cliConfig, flags, output, workDir} = options\n const projectId = cliConfig?.api?.projectId\n let organizationId: string | undefined\n\n const loadInDashboard = flags['load-in-dashboard']\n\n // Check studio dependency versions\n await checkStudioDependencyVersions(workDir, output)\n\n const {installedSanityVersion} = await checkRequiredDependencies(options)\n\n // Check if auto-updates are enabled\n const autoUpdatesEnabled = shouldAutoUpdate({cliConfig, flags, output})\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSanityVersion = semverParse(installedSanityVersion)?.version\n if (!cleanSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n\n const sanityDependencies = [\n {name: 'sanity', version: cleanSanityVersion},\n {name: '@sanity/vision', version: cleanSanityVersion},\n ]\n\n output.log(`${logSymbols.info} Running with auto-updates enabled`)\n\n // Check local versions against deployed versions\n let result: Awaited<ReturnType<typeof compareDependencyVersions>> | undefined\n\n const appId = getAppId(cliConfig)\n\n try {\n result = await compareDependencyVersions(sanityDependencies, workDir, {appId})\n } catch (err) {\n output.warn(`Failed to compare local versions against auto-updating versions: ${err}`)\n }\n\n if (result?.unresolvedPrerelease.length) {\n for (const mod of result.unresolvedPrerelease) {\n output.warn(\n `Your local version of ${mod.pkg} (${mod.version}) is a prerelease not available on the auto-updates CDN. The locally installed version will be used.`,\n )\n }\n }\n\n // mismatch between local and auto-updating dependencies\n if (result?.mismatched.length) {\n const message =\n `The following local package versions are different from the versions currently served at runtime.\\n` +\n `When using auto updates, we recommend that you run with the same versions locally as will be used when deploying.\\n\\n` +\n `${result.mismatched.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')}\\n\\n`\n\n if (isInteractive()) {\n const shouldUpgrade = await confirm({\n default: true,\n message: styleText('yellow', `${message}Do you want to upgrade local versions?`),\n })\n if (shouldUpgrade) {\n await upgradePackages(\n {\n packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,\n packages: result.mismatched.map((res) => [res.pkg, res.remote]),\n },\n {output, workDir},\n )\n }\n } else {\n // In this case we warn the user but we don't ask them if they want to upgrade because it's not interactive.\n output.log(styleText('yellow', message))\n }\n }\n }\n\n if (cliConfig?.schemaExtraction?.enabled) {\n output.log(`${logSymbols.info} Running dev server with schema extraction enabled`)\n }\n\n const config = getDevServerConfig({cliConfig, flags, output, workDir})\n\n if (loadInDashboard) {\n if (!projectId) {\n output.error('Project Id is required to load in dashboard', {exit: 1})\n }\n\n try {\n const project = await getProjectById(projectId!)\n organizationId = project.organizationId!\n } catch (error) {\n devDebug('Error getting organization id from project id', error)\n output.error('Failed to get organization id from project id', {exit: 1})\n }\n }\n\n try {\n const startTime = Date.now()\n const spin = spinner('Starting dev server').start()\n const {close, server} = await startDevServer(config)\n\n const {info: loggerInfo} = server.config.logger\n const {port} = server.config.server\n const httpHost = config.httpHost || 'localhost'\n\n if (loadInDashboard) {\n spin.succeed()\n\n output.log(`Dev server started on port ${port}`)\n output.log(`View your studio in the Sanity dashboard here:`)\n output.log(\n styleText(\n ['blue', 'underline'],\n await getDashboardAppURL({\n httpHost,\n httpPort: port,\n organizationId: organizationId!,\n }),\n ),\n )\n } else {\n const startupDuration = Date.now() - startTime\n const url = `http://${httpHost || 'localhost'}:${port}${config.basePath}`\n const appType = 'Sanity Studio'\n\n const viteVersion = await getLocalPackageVersion('vite', import.meta.url)\n spin.succeed()\n\n loggerInfo(\n `${appType} ` +\n `using ${styleText('cyan', `vite@${viteVersion}`)} ` +\n `ready in ${styleText('cyan', `${Math.ceil(startupDuration)}ms`)} ` +\n `and running at ${styleText('cyan', url)}`,\n )\n }\n\n return {close}\n } catch (err) {\n devDebug('Error starting studio dev server', err)\n throw gracefulServerDeath('dev', config.httpHost, config.httpPort, err)\n }\n}\n"],"names":["styleText","isInteractive","confirm","logSymbols","spinner","parse","semverParse","startDevServer","gracefulServerDeath","getProjectById","getAppId","compareDependencyVersions","getLocalPackageVersion","getPackageManagerChoice","upgradePackages","checkRequiredDependencies","checkStudioDependencyVersions","shouldAutoUpdate","devDebug","getDashboardAppURL","getDevServerConfig","startStudioDevServer","options","cliConfig","flags","output","workDir","projectId","api","organizationId","loadInDashboard","installedSanityVersion","autoUpdatesEnabled","cleanSanityVersion","version","Error","sanityDependencies","name","log","info","result","appId","err","warn","unresolvedPrerelease","length","mod","pkg","mismatched","message","map","installed","remote","join","shouldUpgrade","default","packageManager","interactive","chosen","packages","res","schemaExtraction","enabled","config","error","exit","project","startTime","Date","now","spin","start","close","server","loggerInfo","logger","port","httpHost","succeed","httpPort","startupDuration","url","basePath","appType","viteVersion","Math","ceil"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,aAAa,QAAO,mBAAkB;AAC9C,SAAQC,OAAO,EAAEC,UAAU,EAAEC,OAAO,QAAO,sBAAqB;AAChE,SAAQC,SAASC,WAAW,QAAO,SAAQ;AAE3C,SAAQC,cAAc,QAAO,4BAA2B;AACxD,SAAQC,mBAAmB,QAAO,sCAAqC;AACvE,SAAQC,cAAc,QAAO,6BAA4B;AACzD,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,yBAAyB,QAAO,0CAAyC;AACjF,SAAQC,sBAAsB,QAAO,uCAAsC;AAC3E,SAAQC,uBAAuB,QAAO,oDAAmD;AACzF,SAAQC,eAAe,QAAO,+CAA8C;AAC5E,SAAQC,yBAAyB,QAAO,wCAAuC;AAC/E,SAAQC,6BAA6B,QAAO,4CAA2C;AACvF,SAAQC,gBAAgB,QAAO,+B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EAAE,CAAC,CAAC,GACnE,CAAC,eAAe,EAAEhF,UAAU,QAAQiF,MAAM;QAEhD;QAEA,OAAO;YAACT;QAAK;IACf,EAAE,OAAO9B,KAAK;QACZxB,SAAS,oCAAoCwB;QAC7C,MAAMlC,oBAAoB,OAAOuD,OAAOc,QAAQ,EAAEd,OAAOgB,QAAQ,EAAErC;IACrE;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/doctor/types.ts"],"sourcesContent":["export interface DoctorCheck {\n name: string\n run(context: DoctorContext): Promise<CheckResult>\n title: string\n}\n\nexport type CheckResultStatus = 'error' | 'passed' | 'warning'\n\nexport type MessageType = 'error' | 'info' | 'success' | 'warning'\n\nexport type SummaryTypes = 'errors' | 'passed' | 'warnings'\n\nexport interface DoctorContext {\n cwd: string\n}\n\nexport interface CheckResult {\n messages: CheckMessage[]\n status: CheckResultStatus\n}\n\nexport interface CheckMessage {\n text: string\n type: MessageType\n\n suggestions?: string[]\n}\n\nexport interface DoctorResults {\n checks: CheckResultWithMeta[]\n summary: Record<SummaryTypes, number>\n}\n\nexport interface CheckResultWithMeta extends CheckResult {\n name: string\n title: string\n}\n"],"names":[],"mappings":"AAiCA,WAGC"}
1
+ {"version":3,"sources":["../../../src/actions/doctor/types.ts"],"sourcesContent":["export interface DoctorCheck {\n name: string\n run(context: DoctorContext): Promise<CheckResult>\n title: string\n}\n\nexport type CheckResultStatus = 'error' | 'passed' | 'warning'\n\nexport type MessageType = 'error' | 'info' | 'success' | 'warning'\n\ntype SummaryTypes = 'errors' | 'passed' | 'warnings'\n\nexport interface DoctorContext {\n cwd: string\n}\n\nexport interface CheckResult {\n messages: CheckMessage[]\n status: CheckResultStatus\n}\n\nexport interface CheckMessage {\n text: string\n type: MessageType\n\n suggestions?: string[]\n}\n\nexport interface DoctorResults {\n checks: CheckResultWithMeta[]\n summary: Record<SummaryTypes, number>\n}\n\nexport interface CheckResultWithMeta extends CheckResult {\n name: string\n title: string\n}\n"],"names":[],"mappings":"AAiCA,WAGC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/graphql/resolveGraphQLApisFromWorkspaces.ts"],"sourcesContent":["import {type Schema} from '@sanity/types'\nimport isPlainObject from 'lodash-es/isPlainObject.js'\nimport {oneline} from 'oneline'\n\nimport {\n type ExtractedGraphQLAPI,\n type GraphQLAPIConfig,\n type SchemaDefinitionish,\n type TypeResolvedGraphQLAPI,\n} from './types.js'\n\nexport interface Source {\n dataset: string\n name: string\n projectId: string\n schema: Schema\n}\n\nexport interface Workspace extends Source {\n unstable_sources: Source[]\n}\n\n/**\n * Minimal source metadata — dataset/projectId pair for a source within a workspace.\n */\nexport interface SourceMetadata {\n dataset: string\n name: string\n projectId: string\n}\n\n/**\n * Minimal workspace metadata — enough for resolving API identifiers without compiling schemas.\n * This matches the raw workspace shape from `defineConfig()` before `resolveConfig()` processes it.\n *\n * The `sources` array mirrors `Workspace.unstable_sources` from the full resolved config.\n * When the raw config includes `unstable_sources`, they are extracted here. Otherwise, the\n * workspace itself is used as a single default source (matching what `resolveConfig()` would do).\n */\nexport interface WorkspaceMetadata {\n dataset: string\n name: string\n projectId: string\n sources: SourceMetadata[]\n}\n\ninterface ResolveGraphQLApisOptions {\n workspaces: Workspace[]\n\n cliConfig?: {graphql?: GraphQLAPIConfig[]}\n}\n\nexport function resolveGraphQLApis({\n cliConfig,\n workspaces,\n}: ResolveGraphQLApisOptions): TypeResolvedGraphQLAPI[] {\n const numSources = workspaces.reduce(\n (count, workspace) => count + workspace.unstable_sources.length,\n 0,\n )\n const multiSource = numSources > 1\n const multiWorkspace = workspaces.length > 1\n const hasGraphQLConfig = Boolean(cliConfig?.graphql)\n\n if (workspaces.length === 0) {\n throw new Error('No studio configuration found')\n }\n\n if (numSources === 0) {\n throw new Error('No sources (project ID / dataset) configured')\n }\n\n // We can only automatically configure if there is a single workspace + source in play\n if ((multiWorkspace || multiSource) && !hasGraphQLConfig) {\n throw new Error(oneline`\n Multiple workspaces/sources configured.\n You must define an array of GraphQL APIs in \\`sanity.cli.ts\\` or \\`sanity.cli.js\\`\n and specify which workspace/source to use.\n `)\n }\n\n // No config is defined, but we have a single workspace + source, so use that\n if (!hasGraphQLConfig) {\n const {dataset, projectId, schema} = workspaces[0].unstable_sources[0]\n return [{dataset, projectId, schemaTypes: getStrippedSchemaTypes(schema)}]\n }\n\n // Explicitly defined config\n const apiDefs = validateCliConfig(cliConfig?.graphql || [])\n return resolveGraphQLAPIsFromConfig(apiDefs, workspaces)\n}\n\n/**\n * Resolve GraphQL API metadata (projectId, dataset, tag, etc.) from raw workspace configs\n * without compiling schemas. This is used when we only need API identifiers, not schema types —\n * e.g. for `graphql undeploy --api` or `graphql list`.\n */\nexport function resolveGraphQLApiMetadata({\n cliConfig,\n workspaces,\n}: {\n cliConfig?: {graphql?: GraphQLAPIConfig[]}\n workspaces: WorkspaceMetadata[]\n}): ExtractedGraphQLAPI[] {\n const numSources = workspaces.reduce((count, ws) => count + ws.sources.length, 0)\n const multiSource = numSources > 1\n const multiWorkspace = workspaces.length > 1\n const hasGraphQLConfig = Boolean(cliConfig?.graphql)\n\n if (workspaces.length === 0) {\n throw new Error('No studio configuration found')\n }\n\n if (numSources === 0) {\n throw new Error('No sources (project ID / dataset) configured')\n }\n\n // We can only automatically configure if there is a single workspace + source in play\n if ((multiWorkspace || multiSource) && !hasGraphQLConfig) {\n throw new Error(oneline`\n Multiple workspaces/sources configured.\n You must define an array of GraphQL APIs in \\`sanity.cli.ts\\` or \\`sanity.cli.js\\`\n and specify which workspace/source to use.\n `)\n }\n\n // Validate that workspaces and their sources have non-empty projectId/dataset.\n // The worker's toWorkspaceMetadata validates this before constructing metadata,\n // but assert here to make the invariant explicit.\n for (const ws of workspaces) {\n if (!ws.projectId || !ws.dataset) {\n throw new Error(\n `Workspace \"${ws.name}\" is missing a projectId or dataset. ` +\n 'Check your studio configuration.',\n )\n }\n for (const source of ws.sources) {\n if (!source.projectId || !source.dataset) {\n throw new Error(\n `Source \"${source.name}\" in workspace \"${ws.name}\" is missing a projectId or dataset. ` +\n 'Check your studio configuration.',\n )\n }\n }\n }\n\n // No config is defined, but we have a single workspace + source, so use that\n if (!hasGraphQLConfig) {\n const {dataset, projectId} = workspaces[0].sources[0]\n return [{dataset, projectId}]\n }\n\n // Explicitly defined config\n const apiDefs = validateCliConfig(cliConfig?.graphql || [])\n return resolveGraphQLApiMetadataFromConfig(apiDefs, workspaces)\n}\n\n/**\n * Shared workspace/source resolution logic for both the metadata and full-compile paths.\n *\n * Both `resolveGraphQLAPIsFromConfig` and `resolveGraphQLApiMetadataFromConfig` need to\n * resolve the workspace and source for each GraphQL API config entry. This helper\n * extracts that shared logic so bug fixes and edge-case handling apply to both paths.\n */\nfunction resolveWorkspaceAndSource<\n TWorkspace extends {name: string},\n TSource extends {name: string},\n>(\n apiDef: GraphQLAPIConfig,\n workspaces: TWorkspace[],\n getSources: (workspace: TWorkspace) => TSource[],\n): {source: TSource; workspace: TWorkspace} {\n const {source: sourceName, workspace: workspaceName} = apiDef\n\n if (!workspaceName && workspaces.length > 1) {\n throw new Error(\n 'Must define `workspace` name in GraphQL API config when multiple workspaces are defined',\n )\n }\n\n // If we only have a single workspace defined, we can assume that is the intended one,\n // even if no `workspace` is defined for the GraphQL API\n const workspace =\n !workspaceName && workspaces.length === 1\n ? workspaces[0]\n : workspaces.find((space) => space.name === (workspaceName || 'default'))\n\n if (!workspace) {\n throw new Error(`Workspace \"${workspaceName || 'default'}\" not found`)\n }\n\n const sources = getSources(workspace)\n\n // If we only have a single source defined, we can assume that is the intended one,\n // even if no `source` is defined for the GraphQL API\n const source =\n !sourceName && sources.length === 1\n ? sources[0]\n : sources.find((src) => src.name === (sourceName || 'default'))\n\n if (!source) {\n throw new Error(\n `Source \"${sourceName || 'default'}\" not found in workspace \"${workspaceName || 'default'}\"`,\n )\n }\n\n return {source, workspace}\n}\n\nfunction resolveGraphQLApiMetadataFromConfig(\n apiDefs: GraphQLAPIConfig[],\n workspaces: WorkspaceMetadata[],\n): ExtractedGraphQLAPI[] {\n return apiDefs.map((apiDef) => {\n const {source} = resolveWorkspaceAndSource(apiDef, workspaces, (ws) => ws.sources)\n\n return {\n dataset: source.dataset,\n filterSuffix: apiDef.filterSuffix,\n generation: apiDef.generation,\n id: apiDef.id,\n nonNullDocumentFields: apiDef.nonNullDocumentFields,\n playground: apiDef.playground,\n projectId: source.projectId,\n tag: apiDef.tag,\n }\n })\n}\n\nfunction resolveGraphQLAPIsFromConfig(\n apiDefs: GraphQLAPIConfig[],\n workspaces: Workspace[],\n): TypeResolvedGraphQLAPI[] {\n return apiDefs.map((apiDef) => {\n const {source} = resolveWorkspaceAndSource(apiDef, workspaces, (ws) => ws.unstable_sources)\n\n return {\n ...apiDef,\n dataset: source.dataset,\n projectId: source.projectId,\n schemaTypes: getStrippedSchemaTypes(source.schema),\n }\n })\n}\n\nfunction validateCliConfig(\n config: GraphQLAPIConfig[],\n configPath = 'sanity.cli.js',\n): GraphQLAPIConfig[] {\n if (!Array.isArray(config)) {\n throw new TypeError(`\"graphql\" key in \"${configPath}\" must be an array if defined`)\n }\n\n if (config.length === 0) {\n throw new Error(`No GraphQL APIs defined in \"${configPath}\"`)\n }\n\n return config\n}\n\nfunction getStrippedSchemaTypes(schema: Schema): SchemaDefinitionish[] {\n const schemaDef = schema._original || {types: []}\n return schemaDef.types.map((type) => stripType(type))\n}\n\nfunction stripType(input: unknown): SchemaDefinitionish {\n return strip(input) as SchemaDefinitionish\n}\n\nfunction strip(input: unknown): unknown {\n if (Array.isArray(input)) {\n return input.map((item) => strip(item)).filter((item) => item !== undefined)\n }\n\n if (isPlainishObject(input)) {\n const stripped: Record<string, unknown> = {}\n for (const key of Object.keys(input)) {\n stripped[key] = strip(input[key])\n }\n return stripped\n }\n\n return isBasicType(input) ? input : undefined\n}\n\nfunction isPlainishObject(input: unknown): input is Record<string, unknown> {\n return isPlainObject(input)\n}\n\nfunction isBasicType(input: unknown): boolean {\n const type = typeof input\n if (type === 'boolean' || type === 'number' || type === 'string') {\n return true\n }\n\n if (type !== 'object') {\n return false\n }\n\n return Array.isArray(input) || input === null || isPlainishObject(input)\n}\n"],"names":["isPlainObject","oneline","resolveGraphQLApis","cliConfig","workspaces","numSources","reduce","count","workspace","unstable_sources","length","multiSource","multiWorkspace","hasGraphQLConfig","Boolean","graphql","Error","dataset","projectId","schema","schemaTypes","getStrippedSchemaTypes","apiDefs","validateCliConfig","resolveGraphQLAPIsFromConfig","resolveGraphQLApiMetadata","ws","sources","name","source","resolveGraphQLApiMetadataFromConfig","resolveWorkspaceAndSource","apiDef","getSources","sourceName","workspaceName","find","space","src","map","filterSuffix","generation","id","nonNullDocumentFields","playground","tag","config","configPath","Array","isArray","TypeError","schemaDef","_original","types","type","stripType","input","strip","item","filter","undefined","isPlainishObject","stripped","key","Object","keys","isBasicType"],"mappings":"AACA,OAAOA,mBAAmB,6BAA4B;AACtD,SAAQC,OAAO,QAAO,UAAS;AAkD/B,OAAO,SAASC,mBAAmB,EACjCC,SAAS,EACTC,UAAU,EACgB;IAC1B,MAAMC,aAAaD,WAAWE,MAAM,CAClC,CAACC,OAAOC,YAAcD,QAAQC,UAAUC,gBAAgB,CAACC,MAAM,EAC/D;IAEF,MAAMC,cAAcN,aAAa;IACjC,MAAMO,iBAAiBR,WAAWM,MAAM,GAAG;IAC3C,MAAMG,mBAAmBC,QAAQX,WAAWY;IAE5C,IAAIX,WAAWM,MAAM,KAAK,GAAG;QAC3B,MAAM,IAAIM,MAAM;IAClB;IAEA,IAAIX,eAAe,GAAG;QACpB,MAAM,IAAIW,MAAM;IAClB;IAEA,sFAAsF;IACtF,IAAI,AAACJ,CAAAA,kBAAkBD,WAAU,KAAM,CAACE,kBAAkB;QACxD,MAAM,IAAIG,MAAMf,OAAO,CAAC;;;;IAIxB,CAAC;IACH;IAEA,6EAA6E;IAC7E,IAAI,CAACY,kBAAkB;QACrB,MAAM,EAACI,OAAO,EAAEC,SAAS,EAAEC,MAAM,EAAC,GAAGf,UAAU,CAAC,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SAASC,UAAUC,KAAc;IAC/B,OAAOC,MAAMD;AACf;AAEA,SAASC,MAAMD,KAAc;IAC3B,IAAIR,MAAMC,OAAO,CAACO,QAAQ;QACxB,OAAOA,MAAMjB,GAAG,CAAC,CAACmB,OAASD,MAAMC,OAAOC,MAAM,CAAC,CAACD,OAASA,SAASE;IACpE;IAEA,IAAIC,iBAAiBL,QAAQ;QAC3B,MAAMM,WAAoC,CAAC;QAC3C,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAACT,OAAQ;YACpCM,QAAQ,CAACC,IAAI,GAAGN,MAAMD,KAAK,CAACO,IAAI;QAClC;QACA,OAAOD;IACT;IAEA,OAAOI,YAAYV,SAASA,QAAQI;AACtC;AAEA,SAASC,iBAAiBL,KAAc;IACtC,OAAOxD,cAAcwD;AACvB;AAEA,SAASU,YAAYV,KAAc;IACjC,MAAMF,OAAO,OAAOE;IACpB,IAAIF,SAAS,aAAaA,SAAS,YAAYA,SAAS,UAAU;QAChE,OAAO;IACT;IAEA,IAAIA,SAAS,UAAU;QACrB,OAAO;IACT;IAEA,OAAON,MAAMC,OAAO,CAACO,UAAUA,UAAU,QAAQK,iBAAiBL;AACpE"}
1
+ {"version":3,"sources":["../../../src/actions/graphql/resolveGraphQLApisFromWorkspaces.ts"],"sourcesContent":["import {type Schema} from '@sanity/types'\nimport isPlainObject from 'lodash-es/isPlainObject.js'\nimport {oneline} from 'oneline'\n\nimport {\n type ExtractedGraphQLAPI,\n type GraphQLAPIConfig,\n type SchemaDefinitionish,\n type TypeResolvedGraphQLAPI,\n} from './types.js'\n\ninterface Source {\n dataset: string\n name: string\n projectId: string\n schema: Schema\n}\n\nexport interface Workspace extends Source {\n unstable_sources: Source[]\n}\n\n/**\n * Minimal source metadata — dataset/projectId pair for a source within a workspace.\n */\nexport interface SourceMetadata {\n dataset: string\n name: string\n projectId: string\n}\n\n/**\n * Minimal workspace metadata — enough for resolving API identifiers without compiling schemas.\n * This matches the raw workspace shape from `defineConfig()` before `resolveConfig()` processes it.\n *\n * The `sources` array mirrors `Workspace.unstable_sources` from the full resolved config.\n * When the raw config includes `unstable_sources`, they are extracted here. Otherwise, the\n * workspace itself is used as a single default source (matching what `resolveConfig()` would do).\n */\nexport interface WorkspaceMetadata {\n dataset: string\n name: string\n projectId: string\n sources: SourceMetadata[]\n}\n\ninterface ResolveGraphQLApisOptions {\n workspaces: Workspace[]\n\n cliConfig?: {graphql?: GraphQLAPIConfig[]}\n}\n\nexport function resolveGraphQLApis({\n cliConfig,\n workspaces,\n}: ResolveGraphQLApisOptions): TypeResolvedGraphQLAPI[] {\n const numSources = workspaces.reduce(\n (count, workspace) => count + workspace.unstable_sources.length,\n 0,\n )\n const multiSource = numSources > 1\n const multiWorkspace = workspaces.length > 1\n const hasGraphQLConfig = Boolean(cliConfig?.graphql)\n\n if (workspaces.length === 0) {\n throw new Error('No studio configuration found')\n }\n\n if (numSources === 0) {\n throw new Error('No sources (project ID / dataset) configured')\n }\n\n // We can only automatically configure if there is a single workspace + source in play\n if ((multiWorkspace || multiSource) && !hasGraphQLConfig) {\n throw new Error(oneline`\n Multiple workspaces/sources configured.\n You must define an array of GraphQL APIs in \\`sanity.cli.ts\\` or \\`sanity.cli.js\\`\n and specify which workspace/source to use.\n `)\n }\n\n // No config is defined, but we have a single workspace + source, so use that\n if (!hasGraphQLConfig) {\n const {dataset, projectId, schema} = workspaces[0].unstable_sources[0]\n return [{dataset, projectId, schemaTypes: getStrippedSchemaTypes(schema)}]\n }\n\n // Explicitly defined config\n const apiDefs = validateCliConfig(cliConfig?.graphql || [])\n return resolveGraphQLAPIsFromConfig(apiDefs, workspaces)\n}\n\n/**\n * Resolve GraphQL API metadata (projectId, dataset, tag, etc.) from raw workspace configs\n * without compiling schemas. This is used when we only need API identifiers, not schema types —\n * e.g. for `graphql undeploy --api` or `graphql list`.\n */\nexport function resolveGraphQLApiMetadata({\n cliConfig,\n workspaces,\n}: {\n cliConfig?: {graphql?: GraphQLAPIConfig[]}\n workspaces: WorkspaceMetadata[]\n}): ExtractedGraphQLAPI[] {\n const numSources = workspaces.reduce((count, ws) => count + ws.sources.length, 0)\n const multiSource = numSources > 1\n const multiWorkspace = workspaces.length > 1\n const hasGraphQLConfig = Boolean(cliConfig?.graphql)\n\n if (workspaces.length === 0) {\n throw new Error('No studio configuration found')\n }\n\n if (numSources === 0) {\n throw new Error('No sources (project ID / dataset) configured')\n }\n\n // We can only automatically configure if there is a single workspace + source in play\n if ((multiWorkspace || multiSource) && !hasGraphQLConfig) {\n throw new Error(oneline`\n Multiple workspaces/sources configured.\n You must define an array of GraphQL APIs in \\`sanity.cli.ts\\` or \\`sanity.cli.js\\`\n and specify which workspace/source to use.\n `)\n }\n\n // Validate that workspaces and their sources have non-empty projectId/dataset.\n // The worker's toWorkspaceMetadata validates this before constructing metadata,\n // but assert here to make the invariant explicit.\n for (const ws of workspaces) {\n if (!ws.projectId || !ws.dataset) {\n throw new Error(\n `Workspace \"${ws.name}\" is missing a projectId or dataset. ` +\n 'Check your studio configuration.',\n )\n }\n for (const source of ws.sources) {\n if (!source.projectId || !source.dataset) {\n throw new Error(\n `Source \"${source.name}\" in workspace \"${ws.name}\" is missing a projectId or dataset. ` +\n 'Check your studio configuration.',\n )\n }\n }\n }\n\n // No config is defined, but we have a single workspace + source, so use that\n if (!hasGraphQLConfig) {\n const {dataset, projectId} = workspaces[0].sources[0]\n return [{dataset, projectId}]\n }\n\n // Explicitly defined config\n const apiDefs = validateCliConfig(cliConfig?.graphql || [])\n return resolveGraphQLApiMetadataFromConfig(apiDefs, workspaces)\n}\n\n/**\n * Shared workspace/source resolution logic for both the metadata and full-compile paths.\n *\n * Both `resolveGraphQLAPIsFromConfig` and `resolveGraphQLApiMetadataFromConfig` need to\n * resolve the workspace and source for each GraphQL API config entry. This helper\n * extracts that shared logic so bug fixes and edge-case handling apply to both paths.\n */\nfunction resolveWorkspaceAndSource<\n TWorkspace extends {name: string},\n TSource extends {name: string},\n>(\n apiDef: GraphQLAPIConfig,\n workspaces: TWorkspace[],\n getSources: (workspace: TWorkspace) => TSource[],\n): {source: TSource; workspace: TWorkspace} {\n const {source: sourceName, workspace: workspaceName} = apiDef\n\n if (!workspaceName && workspaces.length > 1) {\n throw new Error(\n 'Must define `workspace` name in GraphQL API config when multiple workspaces are defined',\n )\n }\n\n // If we only have a single workspace defined, we can assume that is the intended one,\n // even if no `workspace` is defined for the GraphQL API\n const workspace =\n !workspaceName && workspaces.length === 1\n ? workspaces[0]\n : workspaces.find((space) => space.name === (workspaceName || 'default'))\n\n if (!workspace) {\n throw new Error(`Workspace \"${workspaceName || 'default'}\" not found`)\n }\n\n const sources = getSources(workspace)\n\n // If we only have a single source defined, we can assume that is the intended one,\n // even if no `source` is defined for the GraphQL API\n const source =\n !sourceName && sources.length === 1\n ? sources[0]\n : sources.find((src) => src.name === (sourceName || 'default'))\n\n if (!source) {\n throw new Error(\n `Source \"${sourceName || 'default'}\" not found in workspace \"${workspaceName || 'default'}\"`,\n )\n }\n\n return {source, workspace}\n}\n\nfunction resolveGraphQLApiMetadataFromConfig(\n apiDefs: GraphQLAPIConfig[],\n workspaces: WorkspaceMetadata[],\n): ExtractedGraphQLAPI[] {\n return apiDefs.map((apiDef) => {\n const {source} = resolveWorkspaceAndSource(apiDef, workspaces, (ws) => ws.sources)\n\n return {\n dataset: source.dataset,\n filterSuffix: apiDef.filterSuffix,\n generation: apiDef.generation,\n id: apiDef.id,\n nonNullDocumentFields: apiDef.nonNullDocumentFields,\n playground: apiDef.playground,\n projectId: source.projectId,\n tag: apiDef.tag,\n }\n })\n}\n\nfunction resolveGraphQLAPIsFromConfig(\n apiDefs: GraphQLAPIConfig[],\n workspaces: Workspace[],\n): TypeResolvedGraphQLAPI[] {\n return apiDefs.map((apiDef) => {\n const {source} = resolveWorkspaceAndSource(apiDef, workspaces, (ws) => ws.unstable_sources)\n\n return {\n ...apiDef,\n dataset: source.dataset,\n projectId: source.projectId,\n schemaTypes: getStrippedSchemaTypes(source.schema),\n }\n })\n}\n\nfunction validateCliConfig(\n config: GraphQLAPIConfig[],\n configPath = 'sanity.cli.js',\n): GraphQLAPIConfig[] {\n if (!Array.isArray(config)) {\n throw new TypeError(`\"graphql\" key in \"${configPath}\" must be an array if defined`)\n }\n\n if (config.length === 0) {\n throw new Error(`No GraphQL APIs defined in \"${configPath}\"`)\n }\n\n return config\n}\n\nfunction getStrippedSchemaTypes(schema: Schema): SchemaDefinitionish[] {\n const schemaDef = schema._original || {types: []}\n return schemaDef.types.map((type) => stripType(type))\n}\n\nfunction stripType(input: unknown): SchemaDefinitionish {\n return strip(input) as SchemaDefinitionish\n}\n\nfunction strip(input: unknown): unknown {\n if (Array.isArray(input)) {\n return input.map((item) => strip(item)).filter((item) => item !== undefined)\n }\n\n if (isPlainishObject(input)) {\n const stripped: Record<string, unknown> = {}\n for (const key of Object.keys(input)) {\n stripped[key] = strip(input[key])\n }\n return stripped\n }\n\n return isBasicType(input) ? input : undefined\n}\n\nfunction isPlainishObject(input: unknown): input is Record<string, unknown> {\n return isPlainObject(input)\n}\n\nfunction isBasicType(input: unknown): boolean {\n const type = typeof input\n if (type === 'boolean' || type === 'number' || type === 'string') {\n return true\n }\n\n if (type !== 'object') {\n return false\n }\n\n return Array.isArray(input) || input === null || isPlainishObject(input)\n}\n"],"names":["isPlainObject","oneline","resolveGraphQLApis","cliConfig","workspaces","numSources","reduce","count","workspace","unstable_sources","length","multiSource","multiWorkspace","hasGraphQLConfig","Boolean","graphql","Error","dataset","projectId","schema","schemaTypes","getStrippedSchemaTypes","apiDefs","validateCliConfig","resolveGraphQLAPIsFromConfig","resolveGraphQLApiMetadata","ws","sources","name","source","resolveGraphQLApiMetadataFromConfig","resolveWorkspaceAndSource","apiDef","getSources","sourceName","workspaceName","find","space","src","map","filterSuffix","generation","id","nonNullDocumentFields","playground","tag","config","configPath","Array","isArray","TypeError","schemaDef","_original","types","type","stripType","input","strip","item","filter","undefined","isPlainishObject","stripped","key","Object","keys","isBasicType"],"mappings":"AACA,OAAOA,mBAA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MF,OAAO,OAAOE;IACpB,IAAIF,SAAS,aAAaA,SAAS,YAAYA,SAAS,UAAU;QAChE,OAAO;IACT;IAEA,IAAIA,SAAS,UAAU;QACrB,OAAO;IACT;IAEA,OAAON,MAAMC,OAAO,CAACO,UAAUA,UAAU,QAAQK,iBAAiBL;AACpE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/init/bootstrapTemplate.ts"],"sourcesContent":["import {Output} from '@sanity/cli-core'\n\nimport {bootstrapLocalTemplate} from './bootstrapLocalTemplate.js'\nimport {bootstrapRemoteTemplate} from './bootstrapRemoteTemplate.js'\nimport {type GenerateConfigOptions} from './createStudioConfig.js'\nimport {type RepoInfo} from './remoteTemplate.js'\n\ninterface BootstrapTemplateOptions {\n autoUpdates: boolean\n bearerToken: string | undefined\n dataset: string\n organizationId: string | undefined\n output: Output\n outputPath: string\n overwriteFiles: boolean\n packageName: string\n projectId: string\n projectName: string\n remoteTemplateInfo: RepoInfo | undefined\n templateName: string\n useTypeScript: boolean\n}\n\nexport async function bootstrapTemplate({\n autoUpdates,\n bearerToken,\n dataset,\n organizationId,\n output,\n outputPath,\n overwriteFiles,\n packageName,\n projectId,\n projectName,\n remoteTemplateInfo,\n templateName,\n useTypeScript,\n}: BootstrapTemplateOptions) {\n const bootstrapVariables: GenerateConfigOptions['variables'] = {\n autoUpdates,\n dataset,\n organizationId,\n projectId,\n projectName,\n }\n\n if (remoteTemplateInfo) {\n return bootstrapRemoteTemplate({\n bearerToken,\n output,\n outputPath,\n packageName,\n repoInfo: remoteTemplateInfo,\n variables: bootstrapVariables,\n })\n }\n\n return bootstrapLocalTemplate({\n output,\n outputPath,\n overwriteFiles,\n packageName,\n templateName,\n useTypeScript,\n variables: bootstrapVariables,\n })\n}\n"],"names":["bootstrapLocalTemplate","bootstrapRemoteTemplate","bootstrapTemplate","autoUpdates","bearerToken","dataset","organizationId","output","outputPath","overwriteFiles","packageName","projectId","projectName","remoteTemplateInfo","templateName","useTypeScript","bootstrapVariables","repoInfo","variables"],"mappings":"AAEA,SAAQA,sBAAsB,QAAO,8BAA6B;AAClE,SAAQC,uBAAuB,QAAO,+BAA8B;AAoBpE,OAAO,eAAeC,kBAAkB,EACtCC,WAAW,EACXC,WAAW,EACXC,OAAO,EACPC,cAAc,EACdC,MAAM,EACNC,UAAU,EACVC,cAAc,EACdC,WAAW,EACXC,SAAS,EACTC,WAAW,EACXC,kBAAkB,EAClBC,YAAY,EACZC,aAAa,EACY;IACzB,MAAMC,qBAAyD;QAC7Db;QACAE;QACAC;QACAK;QACAC;IACF;IAEA,IAAIC,oBAAoB;QACtB,OAAOZ,wBAAwB;YAC7BG;YACAG;YACAC;YACAE;YACAO,UAAUJ;YACVK,WAAWF;QACb;IACF;IAEA,OAAOhB,uBAAuB;QAC5BO;QACAC;QACAC;QACAC;QACAI;QACAC;QACAG,WAAWF;IACb;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/init/bootstrapTemplate.ts"],"sourcesContent":["import {Output} from '@sanity/cli-core'\n\nimport {bootstrapLocalTemplate} from './bootstrapLocalTemplate.js'\nimport {bootstrapRemoteTemplate} from './bootstrapRemoteTemplate.js'\nimport {type GenerateConfigOptions} from './createStudioConfig.js'\nimport {type RepoInfo} from './remoteTemplate.js'\n\ninterface BootstrapTemplateOptions {\n autoUpdates: boolean\n bearerToken: string | undefined\n dataset: string\n organizationId: string | undefined\n output: Output\n outputPath: string\n packageName: string\n projectId: string\n projectName: string\n remoteTemplateInfo: RepoInfo | undefined\n templateName: string\n\n useTypeScript: boolean\n\n overwriteFiles?: boolean\n}\n\nexport async function bootstrapTemplate({\n autoUpdates,\n bearerToken,\n dataset,\n organizationId,\n output,\n outputPath,\n overwriteFiles,\n packageName,\n projectId,\n projectName,\n remoteTemplateInfo,\n templateName,\n useTypeScript,\n}: BootstrapTemplateOptions) {\n const bootstrapVariables: GenerateConfigOptions['variables'] = {\n autoUpdates,\n dataset,\n organizationId,\n projectId,\n projectName,\n }\n\n if (remoteTemplateInfo) {\n return bootstrapRemoteTemplate({\n bearerToken,\n output,\n outputPath,\n packageName,\n repoInfo: remoteTemplateInfo,\n variables: bootstrapVariables,\n })\n }\n\n return bootstrapLocalTemplate({\n output,\n outputPath,\n overwriteFiles,\n packageName,\n templateName,\n useTypeScript,\n variables: bootstrapVariables,\n })\n}\n"],"names":["bootstrapLocalTemplate","bootstrapRemoteTemplate","bootstrapTemplate","autoUpdates","bearerToken","dataset","organizationId","output","outputPath","overwriteFiles","packageName","projectId","projectName","remoteTemplateInfo","templateName","useTypeScript","bootstrapVariables","repoInfo","variables"],"mappings":"AAEA,SAAQA,sBAAsB,QAAO,8BAA6B;AAClE,SAAQC,uBAAuB,QAAO,+BAA8B;AAsBpE,OAAO,eAAeC,kBAAkB,EACtCC,WAAW,EACXC,WAAW,EACXC,OAAO,EACPC,cAAc,EACdC,MAAM,EACNC,UAAU,EACVC,cAAc,EACdC,WAAW,EACXC,SAAS,EACTC,WAAW,EACXC,kBAAkB,EAClBC,YAAY,EACZC,aAAa,EACY;IACzB,MAAMC,qBAAyD;QAC7Db;QACAE;QACAC;QACAK;QACAC;IACF;IAEA,IAAIC,oBAAoB;QACtB,OAAOZ,wBAAwB;YAC7BG;YACAG;YACAC;YACAE;YACAO,UAAUJ;YACVK,WAAWF;QACb;IACF;IAEA,OAAOhB,uBAAuB;QAC5BO;QACAC;QACAC;QACAC;QACAI;QACAC;QACAG,WAAWF;IACb;AACF"}
@@ -1,11 +1,11 @@
1
1
  import { readPackageJson } from '@sanity/cli-core';
2
- import semver from 'semver';
2
+ import { coerce } from 'semver';
3
3
  export async function checkNextJsReactCompatibility({ detectedFramework, output, outputPath }) {
4
4
  const packageJson = await readPackageJson(`${outputPath}/package.json`);
5
5
  const reactVersion = packageJson?.dependencies?.react;
6
6
  if (reactVersion) {
7
- const isUsingReact19 = semver.coerce(reactVersion)?.major === 19;
8
- const isUsingNextJs15 = semver.coerce(detectedFramework?.detectedVersion)?.major === 15;
7
+ const isUsingReact19 = coerce(reactVersion)?.major === 19;
8
+ const isUsingNextJs15 = coerce(detectedFramework?.detectedVersion)?.major === 15;
9
9
  if (isUsingNextJs15 && isUsingReact19) {
10
10
  output.warn('╭────────────────────────────────────────────────────────────╮');
11
11
  output.warn('│ │');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/init/checkNextJsReactCompatibility.ts"],"sourcesContent":["import {Output, readPackageJson} from '@sanity/cli-core'\nimport semver from 'semver'\n\nimport {VersionedFramework} from './types.js'\n\ninterface CheckCompatibilityOptions {\n detectedFramework: VersionedFramework\n output: Output\n outputPath: string\n}\n\nexport async function checkNextJsReactCompatibility({\n detectedFramework,\n output,\n outputPath,\n}: CheckCompatibilityOptions) {\n const packageJson = await readPackageJson(`${outputPath}/package.json`)\n const reactVersion = packageJson?.dependencies?.react\n\n if (reactVersion) {\n const isUsingReact19 = semver.coerce(reactVersion)?.major === 19\n const isUsingNextJs15 = semver.coerce(detectedFramework?.detectedVersion)?.major === 15\n\n if (isUsingNextJs15 && isUsingReact19) {\n output.warn('╭────────────────────────────────────────────────────────────╮')\n output.warn('│ │')\n output.warn('│ It looks like you are using Next.js 15 and React 19 │')\n output.warn('│ Please read our compatibility guide. │')\n output.warn('│ https://www.sanity.io/help/react-19 │')\n output.warn('│ │')\n output.warn('╰────────────────────────────────────────────────────────────╯')\n }\n }\n}\n"],"names":["readPackageJson","semver","checkNextJsReactCompatibility","detectedFramework","output","outputPath","packageJson","reactVersion","dependencies","react","isUsingReact19","coerce","major","isUsingNextJs15","detectedVersion","warn"],"mappings":"AAAA,SAAgBA,eAAe,QAAO,mBAAkB;AACxD,OAAOC,YAAY,SAAQ;AAU3B,OAAO,eAAeC,8BAA8B,EAClDC,iBAAiB,EACjBC,MAAM,EACNC,UAAU,EACgB;IAC1B,MAAMC,cAAc,MAAMN,gBAAgB,GAAGK,WAAW,aAAa,CAAC;IACtE,MAAME,eAAeD,aAAaE,cAAcC;IAEhD,IAAIF,cAAc;QAChB,MAAMG,iBAAiBT,OAAOU,MAAM,CAACJ,eAAeK,UAAU;QAC9D,MAAMC,kBAAkBZ,OAAOU,MAAM,CAACR,mBAAmBW,kBAAkBF,UAAU;QAErF,IAAIC,mBAAmBH,gBAAgB;YACrCN,OAAOW,IAAI,CAAC;YACZX,OAAOW,IAAI,CAAC;YACZX,OAAOW,IAAI,CAAC;YACZX,OAAOW,IAAI,CAAC;YACZX,OAAOW,IAAI,CAAC;YACZX,OAAOW,IAAI,CAAC;YACZX,OAAOW,IAAI,CAAC;QACd;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/init/checkNextJsReactCompatibility.ts"],"sourcesContent":["import {Output, readPackageJson} from '@sanity/cli-core'\nimport {coerce} from 'semver'\n\nimport {VersionedFramework} from './types.js'\n\ninterface CheckCompatibilityOptions {\n detectedFramework: VersionedFramework\n output: Output\n outputPath: string\n}\n\nexport async function checkNextJsReactCompatibility({\n detectedFramework,\n output,\n outputPath,\n}: CheckCompatibilityOptions) {\n const packageJson = await readPackageJson(`${outputPath}/package.json`)\n const reactVersion = packageJson?.dependencies?.react\n\n if (reactVersion) {\n const isUsingReact19 = coerce(reactVersion)?.major === 19\n const isUsingNextJs15 = coerce(detectedFramework?.detectedVersion)?.major === 15\n\n if (isUsingNextJs15 && isUsingReact19) {\n output.warn('╭────────────────────────────────────────────────────────────╮')\n output.warn('│ │')\n output.warn('│ It looks like you are using Next.js 15 and React 19 │')\n output.warn('│ Please read our compatibility guide. │')\n output.warn('│ https://www.sanity.io/help/react-19 │')\n output.warn('│ │')\n output.warn('╰────────────────────────────────────────────────────────────╯')\n }\n }\n}\n"],"names":["readPackageJson","coerce","checkNextJsReactCompatibility","detectedFramework","output","outputPath","packageJson","reactVersion","dependencies","react","isUsingReact19","major","isUsingNextJs15","detectedVersion","warn"],"mappings":"AAAA,SAAgBA,eAAe,QAAO,mBAAkB;AACxD,SAAQC,MAAM,QAAO,SAAQ;AAU7B,OAAO,eAAeC,8BAA8B,EAClDC,iBAAiB,EACjBC,MAAM,EACNC,UAAU,EACgB;IAC1B,MAAMC,cAAc,MAAMN,gBAAgB,GAAGK,WAAW,aAAa,CAAC;IACtE,MAAME,eAAeD,aAAaE,cAAcC;IAEhD,IAAIF,cAAc;QAChB,MAAMG,iBAAiBT,OAAOM,eAAeI,UAAU;QACvD,MAAMC,kBAAkBX,OAAOE,mBAAmBU,kBAAkBF,UAAU;QAE9E,IAAIC,mBAAmBF,gBAAgB;YACrCN,OAAOU,IAAI,CAAC;YACZV,OAAOU,IAAI,CAAC;YACZV,OAAOU,IAAI,CAAC;YACZV,OAAOU,IAAI,CAAC;YACZV,OAAOU,IAAI,CAAC;YACZV,OAAOU,IAAI,CAAC;YACZV,OAAOU,IAAI,CAAC;QACd;IACF;AACF"}
@@ -0,0 +1,287 @@
1
+ import { styleText } from 'node:util';
2
+ import { subdebug } from '@sanity/cli-core';
3
+ import { logSymbols, spinner } from '@sanity/cli-core/ux';
4
+ import { frameworks } from '@vercel/frameworks';
5
+ import deburr from 'lodash-es/deburr.js';
6
+ import { promptForConfigFiles } from '../../prompts/init/nextjs.js';
7
+ import { getCliUser } from '../../services/user.js';
8
+ import { CLIInitStepCompleted } from '../../telemetry/init.telemetry.js';
9
+ import { detectFrameworkRecord } from '../../util/detectFramework.js';
10
+ import { getProjectDefaults } from '../../util/getProjectDefaults.js';
11
+ import { validateSession } from '../auth/ensureAuthenticated.js';
12
+ import { getProviderName } from '../auth/getProviderName.js';
13
+ import { login } from '../auth/login/login.js';
14
+ import { setupMCP } from '../mcp/setupMCP.js';
15
+ import { checkNextJsReactCompatibility } from './checkNextJsReactCompatibility.js';
16
+ import { determineAppTemplate } from './determineAppTemplate.js';
17
+ import { createOrAppendEnvVars } from './env/createOrAppendEnvVars.js';
18
+ import { initApp } from './initApp.js';
19
+ import { InitError } from './initError.js';
20
+ import { flagOrDefault, shouldPrompt, writeStagingEnvIfNeeded } from './initHelpers.js';
21
+ import { initNextJs } from './initNextJs.js';
22
+ import { initStudio } from './initStudio.js';
23
+ import { getPlan } from './plan/getPlan.js';
24
+ import { createProjectFromName } from './project/createProjectFromName.js';
25
+ import { getProjectDetails } from './project/getProjectDetails.js';
26
+ import { getProjectOutputPath } from './project/getProjectOutputPath.js';
27
+ import { checkIsRemoteTemplate, getGitHubRepoInfo } from './remoteTemplate.js';
28
+ const debug = subdebug('init');
29
+ export async function initAction(options, context) {
30
+ const { output, workDir } = context;
31
+ if (options.argType) {
32
+ throw new InitError(options.argType === 'plugin' ? 'Initializing plugins through the CLI is no longer supported' : `Unknown init type "${options.argType}"`, 1);
33
+ }
34
+ const trace = context.telemetry.trace(CLIInitStepCompleted);
35
+ if (options.reconfigure) {
36
+ throw new InitError('--reconfigure is deprecated - manual configuration is now required', 1);
37
+ }
38
+ if (options.project && options.organization) {
39
+ throw new InitError('You have specified both a project and an organization. To move a project to an organization please visit https://www.sanity.io/manage', 1);
40
+ }
41
+ const defaultConfig = options.datasetDefault;
42
+ let showDefaultConfigPrompt = !defaultConfig;
43
+ if (options.dataset || options.visibility || options.datasetDefault || options.unattended) {
44
+ showDefaultConfigPrompt = false;
45
+ }
46
+ const detectedFramework = await detectFrameworkRecord({
47
+ frameworkList: frameworks,
48
+ rootPath: workDir
49
+ });
50
+ const isNextJs = detectedFramework?.slug === 'nextjs';
51
+ let remoteTemplateInfo;
52
+ if (options.template && checkIsRemoteTemplate(options.template)) {
53
+ remoteTemplateInfo = await getGitHubRepoInfo(options.template, options.templateToken);
54
+ }
55
+ if (detectedFramework && detectedFramework.slug !== 'sanity' && remoteTemplateInfo) {
56
+ throw new InitError(`A remote template cannot be used with a detected framework. Detected: ${detectedFramework.name}`, 1);
57
+ }
58
+ const isAppTemplate = options.template ? determineAppTemplate(options.template) : false;
59
+ if (options.unattended) {
60
+ checkFlagsInUnattendedMode(options, {
61
+ isAppTemplate,
62
+ isNextJs
63
+ });
64
+ }
65
+ trace.start();
66
+ trace.log({
67
+ flags: {
68
+ bare: options.bare,
69
+ coupon: options.coupon,
70
+ defaultConfig,
71
+ env: options.env,
72
+ git: typeof options.git === 'string' ? options.git : undefined,
73
+ plan: options.projectPlan,
74
+ reconfigure: options.reconfigure,
75
+ unattended: options.unattended
76
+ },
77
+ step: 'start'
78
+ });
79
+ const planId = await getPlan(options, output, trace);
80
+ let envFilenameDefault = '.env';
81
+ if (detectedFramework && detectedFramework.slug === 'nextjs') {
82
+ envFilenameDefault = '.env.local';
83
+ }
84
+ const envFilename = typeof options.env === 'string' ? options.env : envFilenameDefault;
85
+ const { user } = await ensureAuthenticated(options, output, trace);
86
+ if (!isAppTemplate) {
87
+ output.log(`${logSymbols.success} Fetching existing projects`);
88
+ output.log('');
89
+ }
90
+ let newProject;
91
+ if (options.projectName) {
92
+ newProject = await createProjectFromName({
93
+ coupon: options.coupon,
94
+ createProjectName: options.projectName,
95
+ dataset: options.dataset,
96
+ organization: options.organization,
97
+ planId,
98
+ user,
99
+ visibility: options.visibility
100
+ });
101
+ }
102
+ const { datasetName, displayName, isFirstProject, organizationId, projectId } = await getProjectDetails({
103
+ coupon: options.coupon,
104
+ dataset: options.dataset,
105
+ datasetDefault: options.datasetDefault,
106
+ isAppTemplate,
107
+ newProject,
108
+ organization: options.organization,
109
+ output,
110
+ planId,
111
+ project: options.project,
112
+ showDefaultConfigPrompt,
113
+ trace,
114
+ unattended: options.unattended,
115
+ user,
116
+ visibility: options.visibility
117
+ });
118
+ if (options.bare) {
119
+ output.log(`${logSymbols.success} Below are your project details`);
120
+ output.log('');
121
+ output.log(`Project ID: ${styleText('cyan', projectId)}`);
122
+ output.log(`Dataset: ${styleText('cyan', datasetName)}`);
123
+ output.log(`\nYou can find your project on Sanity Manage — https://www.sanity.io/manage/project/${projectId}\n`);
124
+ trace.complete();
125
+ return;
126
+ }
127
+ let initNext = flagOrDefault(options.nextjsAddConfigFiles, false);
128
+ if (isNextJs && shouldPrompt(options.unattended, options.nextjsAddConfigFiles)) {
129
+ initNext = await promptForConfigFiles();
130
+ }
131
+ trace.log({
132
+ detectedFramework: detectedFramework?.name,
133
+ selectedOption: initNext ? 'yes' : 'no',
134
+ step: 'useDetectedFramework'
135
+ });
136
+ const sluggedName = deburr(displayName.toLowerCase()).replaceAll(/\s+/g, '-').replaceAll(/[^a-z0-9-]/g, '');
137
+ const initFramework = initNext;
138
+ const defaults = await getProjectDefaults({
139
+ isPlugin: false,
140
+ workDir
141
+ });
142
+ const outputPath = await getProjectOutputPath({
143
+ initFramework,
144
+ outputPath: options.outputPath,
145
+ sluggedName,
146
+ unattended: options.unattended,
147
+ useEnv: Boolean(options.env),
148
+ workDir
149
+ });
150
+ const mcpResult = await setupMCP({
151
+ mode: options.mcpMode
152
+ });
153
+ trace.log({
154
+ configuredEditors: mcpResult.configuredEditors,
155
+ detectedEditors: mcpResult.detectedEditors,
156
+ skipped: mcpResult.skipped,
157
+ step: 'mcpSetup'
158
+ });
159
+ if (mcpResult.error) {
160
+ trace.error(mcpResult.error);
161
+ }
162
+ const mcpConfigured = mcpResult.configuredEditors;
163
+ const { alreadyConfiguredEditors } = mcpResult;
164
+ if (alreadyConfiguredEditors.length > 0) {
165
+ const label = alreadyConfiguredEditors.length === 1 ? `${alreadyConfiguredEditors[0]} already configured for Sanity MCP` : `${alreadyConfiguredEditors.length} editors already configured for Sanity MCP`;
166
+ spinner(label).start().succeed();
167
+ }
168
+ if (isNextJs) {
169
+ await checkNextJsReactCompatibility({
170
+ detectedFramework,
171
+ output,
172
+ outputPath
173
+ });
174
+ }
175
+ if (initNext) {
176
+ await initNextJs({
177
+ datasetName,
178
+ detectedFramework,
179
+ envFilename,
180
+ mcpConfigured,
181
+ options,
182
+ output,
183
+ projectId,
184
+ trace,
185
+ workDir
186
+ });
187
+ trace.complete();
188
+ return;
189
+ }
190
+ if (options.env) {
191
+ await createOrAppendEnvVars({
192
+ envVars: {
193
+ DATASET: datasetName,
194
+ PROJECT_ID: projectId
195
+ },
196
+ filename: envFilename,
197
+ framework: detectedFramework,
198
+ log: false,
199
+ output,
200
+ outputPath
201
+ });
202
+ await writeStagingEnvIfNeeded(output, outputPath);
203
+ trace.complete();
204
+ return;
205
+ }
206
+ const sharedParams = {
207
+ defaults,
208
+ mcpConfigured,
209
+ options,
210
+ organizationId,
211
+ output,
212
+ outputPath,
213
+ remoteTemplateInfo,
214
+ sluggedName,
215
+ trace,
216
+ workDir
217
+ };
218
+ await (isAppTemplate ? initApp({
219
+ ...sharedParams,
220
+ datasetName,
221
+ projectId
222
+ }) : initStudio({
223
+ ...sharedParams,
224
+ datasetName,
225
+ displayName,
226
+ isFirstProject,
227
+ projectId
228
+ }));
229
+ trace.complete();
230
+ }
231
+ function checkFlagsInUnattendedMode(options, { isAppTemplate, isNextJs }) {
232
+ debug('Unattended mode, validating required options');
233
+ if (options.projectName && !options.organization) {
234
+ throw new InitError('`--project-name` requires `--organization <id>` in unattended mode', 1);
235
+ }
236
+ if (isAppTemplate) {
237
+ if (!options.outputPath) {
238
+ throw new InitError('`--output-path` must be specified in unattended mode', 1);
239
+ }
240
+ const hasProjectFlag = Boolean(options.project || options.projectName);
241
+ if (!hasProjectFlag && !options.organization) {
242
+ throw new InitError('The --organization flag is required for app templates in unattended mode. ' + 'Use --organization <id>, or pass --project <id> / --project-name <name>.', 1);
243
+ }
244
+ return;
245
+ }
246
+ if (!isNextJs && !options.bare && !options.outputPath) {
247
+ throw new InitError('`--output-path` must be specified in unattended mode', 1);
248
+ }
249
+ if (!options.project && !options.projectName) {
250
+ throw new InitError('`--project <id>` or `--project-name <name>` must be specified in unattended mode', 1);
251
+ }
252
+ }
253
+ async function ensureAuthenticated(options, output, trace) {
254
+ const user = await validateSession();
255
+ if (user) {
256
+ trace.log({
257
+ alreadyLoggedIn: true,
258
+ step: 'login'
259
+ });
260
+ output.log(`${logSymbols.success} You are logged in as ${user.email} using ${getProviderName(user.provider)}`);
261
+ return {
262
+ user
263
+ };
264
+ }
265
+ if (options.unattended) {
266
+ throw new InitError('Must be logged in to run this command in unattended mode, run `sanity login`', 1);
267
+ }
268
+ trace.log({
269
+ step: 'login'
270
+ });
271
+ try {
272
+ await login({
273
+ output,
274
+ telemetry: trace.newContext('login')
275
+ });
276
+ } catch (error) {
277
+ const message = error instanceof Error ? error.message : String(error);
278
+ throw new InitError(`Login failed: ${message}`, 1);
279
+ }
280
+ const loggedInUser = await getCliUser();
281
+ output.log(`${logSymbols.success} You are logged in as ${loggedInUser.email} using ${getProviderName(loggedInUser.provider)}`);
282
+ return {
283
+ user: loggedInUser
284
+ };
285
+ }
286
+
287
+ //# sourceMappingURL=initAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/actions/init/initAction.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {type SanityOrgUser, subdebug, type TelemetryUserProperties} from '@sanity/cli-core'\nimport {logSymbols, spinner} from '@sanity/cli-core/ux'\nimport {type TelemetryTrace} from '@sanity/telemetry'\nimport {type Framework, frameworks} from '@vercel/frameworks'\nimport deburr from 'lodash-es/deburr.js'\n\nimport {promptForConfigFiles} from '../../prompts/init/nextjs.js'\nimport {getCliUser} from '../../services/user.js'\nimport {CLIInitStepCompleted, type InitStepResult} from '../../telemetry/init.telemetry.js'\nimport {detectFrameworkRecord} from '../../util/detectFramework.js'\nimport {getProjectDefaults} from '../../util/getProjectDefaults.js'\nimport {validateSession} from '../auth/ensureAuthenticated.js'\nimport {getProviderName} from '../auth/getProviderName.js'\nimport {login} from '../auth/login/login.js'\nimport {setupMCP} from '../mcp/setupMCP.js'\nimport {checkNextJsReactCompatibility} from './checkNextJsReactCompatibility.js'\nimport {determineAppTemplate} from './determineAppTemplate.js'\nimport {createOrAppendEnvVars} from './env/createOrAppendEnvVars.js'\nimport {initApp} from './initApp.js'\nimport {InitError} from './initError.js'\nimport {flagOrDefault, shouldPrompt, writeStagingEnvIfNeeded} from './initHelpers.js'\nimport {initNextJs} from './initNextJs.js'\nimport {initStudio} from './initStudio.js'\nimport {getPlan} from './plan/getPlan.js'\nimport {createProjectFromName} from './project/createProjectFromName.js'\nimport {getProjectDetails} from './project/getProjectDetails.js'\nimport {getProjectOutputPath} from './project/getProjectOutputPath.js'\nimport {checkIsRemoteTemplate, getGitHubRepoInfo, type RepoInfo} from './remoteTemplate.js'\nimport {type InitContext, type InitOptions} from './types.js'\n\nconst debug = subdebug('init')\n\nexport async function initAction(options: InitOptions, context: InitContext): Promise<void> {\n const {output, workDir} = context\n\n if (options.argType) {\n throw new InitError(\n options.argType === 'plugin'\n ? 'Initializing plugins through the CLI is no longer supported'\n : `Unknown init type \"${options.argType}\"`,\n 1,\n )\n }\n\n const trace = context.telemetry.trace(CLIInitStepCompleted)\n\n if (options.reconfigure) {\n throw new InitError('--reconfigure is deprecated - manual configuration is now required', 1)\n }\n\n if (options.project && options.organization) {\n throw new InitError(\n 'You have specified both a project and an organization. To move a project to an organization please visit https://www.sanity.io/manage',\n 1,\n )\n }\n\n const defaultConfig = options.datasetDefault\n let showDefaultConfigPrompt = !defaultConfig\n if (options.dataset || options.visibility || options.datasetDefault || options.unattended) {\n showDefaultConfigPrompt = false\n }\n\n const detectedFramework = await detectFrameworkRecord({\n frameworkList: frameworks as readonly Framework[],\n rootPath: workDir,\n })\n const isNextJs = detectedFramework?.slug === 'nextjs'\n\n let remoteTemplateInfo: RepoInfo | undefined\n if (options.template && checkIsRemoteTemplate(options.template)) {\n remoteTemplateInfo = await getGitHubRepoInfo(options.template, options.templateToken)\n }\n\n if (detectedFramework && detectedFramework.slug !== 'sanity' && remoteTemplateInfo) {\n throw new InitError(\n `A remote template cannot be used with a detected framework. Detected: ${detectedFramework.name}`,\n 1,\n )\n }\n\n const isAppTemplate = options.template ? determineAppTemplate(options.template) : false\n\n if (options.unattended) {\n checkFlagsInUnattendedMode(options, {isAppTemplate, isNextJs})\n }\n\n trace.start()\n trace.log({\n flags: {\n bare: options.bare,\n coupon: options.coupon,\n defaultConfig,\n env: options.env,\n git: typeof options.git === 'string' ? options.git : undefined,\n plan: options.projectPlan,\n reconfigure: options.reconfigure,\n unattended: options.unattended,\n },\n step: 'start',\n })\n\n const planId = await getPlan(options, output, trace)\n\n let envFilenameDefault = '.env'\n if (detectedFramework && detectedFramework.slug === 'nextjs') {\n envFilenameDefault = '.env.local'\n }\n const envFilename = typeof options.env === 'string' ? options.env : envFilenameDefault\n\n const {user} = await ensureAuthenticated(options, output, trace)\n if (!isAppTemplate) {\n output.log(`${logSymbols.success} Fetching existing projects`)\n output.log('')\n }\n\n let newProject: string | undefined\n if (options.projectName) {\n newProject = await createProjectFromName({\n coupon: options.coupon,\n createProjectName: options.projectName,\n dataset: options.dataset,\n organization: options.organization,\n planId,\n user,\n visibility: options.visibility,\n })\n }\n\n const {datasetName, displayName, isFirstProject, organizationId, projectId} =\n await getProjectDetails({\n coupon: options.coupon,\n dataset: options.dataset,\n datasetDefault: options.datasetDefault,\n isAppTemplate,\n newProject,\n organization: options.organization,\n output,\n planId,\n project: options.project,\n showDefaultConfigPrompt,\n trace,\n unattended: options.unattended,\n user,\n visibility: options.visibility,\n })\n\n if (options.bare) {\n output.log(`${logSymbols.success} Below are your project details`)\n output.log('')\n output.log(`Project ID: ${styleText('cyan', projectId)}`)\n output.log(`Dataset: ${styleText('cyan', datasetName)}`)\n output.log(\n `\\nYou can find your project on Sanity Manage — https://www.sanity.io/manage/project/${projectId}\\n`,\n )\n trace.complete()\n return\n }\n\n let initNext = flagOrDefault(options.nextjsAddConfigFiles, false)\n if (isNextJs && shouldPrompt(options.unattended, options.nextjsAddConfigFiles)) {\n initNext = await promptForConfigFiles()\n }\n\n trace.log({\n detectedFramework: detectedFramework?.name,\n selectedOption: initNext ? 'yes' : 'no',\n step: 'useDetectedFramework',\n })\n\n const sluggedName = deburr(displayName.toLowerCase())\n .replaceAll(/\\s+/g, '-')\n .replaceAll(/[^a-z0-9-]/g, '')\n\n const initFramework = initNext\n\n const defaults = await getProjectDefaults({isPlugin: false, workDir})\n\n const outputPath = await getProjectOutputPath({\n initFramework,\n outputPath: options.outputPath,\n sluggedName,\n unattended: options.unattended,\n useEnv: Boolean(options.env),\n workDir,\n })\n\n const mcpResult = await setupMCP({mode: options.mcpMode})\n\n trace.log({\n configuredEditors: mcpResult.configuredEditors,\n detectedEditors: mcpResult.detectedEditors,\n skipped: mcpResult.skipped,\n step: 'mcpSetup',\n })\n if (mcpResult.error) {\n trace.error(mcpResult.error)\n }\n const mcpConfigured = mcpResult.configuredEditors\n\n const {alreadyConfiguredEditors} = mcpResult\n if (alreadyConfiguredEditors.length > 0) {\n const label =\n alreadyConfiguredEditors.length === 1\n ? `${alreadyConfiguredEditors[0]} already configured for Sanity MCP`\n : `${alreadyConfiguredEditors.length} editors already configured for Sanity MCP`\n spinner(label).start().succeed()\n }\n\n if (isNextJs) {\n await checkNextJsReactCompatibility({\n detectedFramework,\n output,\n outputPath,\n })\n }\n\n if (initNext) {\n await initNextJs({\n datasetName,\n detectedFramework,\n envFilename,\n mcpConfigured,\n options,\n output,\n projectId,\n trace,\n workDir,\n })\n trace.complete()\n return\n }\n\n if (options.env) {\n await createOrAppendEnvVars({\n envVars: {\n DATASET: datasetName,\n PROJECT_ID: projectId,\n },\n filename: envFilename,\n framework: detectedFramework,\n log: false,\n output,\n outputPath,\n })\n await writeStagingEnvIfNeeded(output, outputPath)\n trace.complete()\n return\n }\n\n const sharedParams = {\n defaults,\n mcpConfigured,\n options,\n organizationId,\n output,\n outputPath,\n remoteTemplateInfo,\n sluggedName,\n trace,\n workDir,\n }\n\n await (isAppTemplate\n ? initApp({...sharedParams, datasetName, projectId})\n : initStudio({\n ...sharedParams,\n datasetName,\n displayName,\n isFirstProject,\n projectId,\n }))\n\n trace.complete()\n}\n\nfunction checkFlagsInUnattendedMode(\n options: InitOptions,\n {isAppTemplate, isNextJs}: {isAppTemplate: boolean; isNextJs: boolean},\n): void {\n debug('Unattended mode, validating required options')\n\n if (options.projectName && !options.organization) {\n throw new InitError('`--project-name` requires `--organization <id>` in unattended mode', 1)\n }\n\n if (isAppTemplate) {\n if (!options.outputPath) {\n throw new InitError('`--output-path` must be specified in unattended mode', 1)\n }\n\n const hasProjectFlag = Boolean(options.project || options.projectName)\n\n if (!hasProjectFlag && !options.organization) {\n throw new InitError(\n 'The --organization flag is required for app templates in unattended mode. ' +\n 'Use --organization <id>, or pass --project <id> / --project-name <name>.',\n 1,\n )\n }\n\n return\n }\n\n if (!isNextJs && !options.bare && !options.outputPath) {\n throw new InitError('`--output-path` must be specified in unattended mode', 1)\n }\n\n if (!options.project && !options.projectName) {\n throw new InitError(\n '`--project <id>` or `--project-name <name>` must be specified in unattended mode',\n 1,\n )\n }\n}\n\nasync function ensureAuthenticated(\n options: InitOptions,\n output: InitContext['output'],\n trace: TelemetryTrace<TelemetryUserProperties, InitStepResult>,\n): Promise<{user: SanityOrgUser}> {\n const user = await validateSession()\n\n if (user) {\n trace.log({alreadyLoggedIn: true, step: 'login'})\n output.log(\n `${logSymbols.success} You are logged in as ${user.email} using ${getProviderName(user.provider)}`,\n )\n return {user}\n }\n\n if (options.unattended) {\n throw new InitError(\n 'Must be logged in to run this command in unattended mode, run `sanity login`',\n 1,\n )\n }\n\n trace.log({step: 'login'})\n\n try {\n await login({\n output,\n telemetry: trace.newContext('login'),\n })\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n throw new InitError(`Login failed: ${message}`, 1)\n }\n\n const loggedInUser = await getCliUser()\n\n output.log(\n `${logSymbols.success} You are logged in as ${loggedInUser.email} using ${getProviderName(loggedInUser.provider)}`,\n )\n return {user: loggedInUser}\n}\n"],"names":["styleText","subdebug","logSymbols","spinner","frameworks","deburr","promptForConfigFiles","getCliUser","CLIInitStepCompleted","detectFrameworkRecord","getProjectDefaults","validateSession","getProviderName","login","setupMCP","checkNextJsReactCompatibility","determineAppTemplate","createOrAppendEnvVars","initApp","InitError","flagOrDefault","shouldPrompt","writeStagingEnvIfNeeded","initNextJs","initStudio","getPlan","createProjectFromName","getProjectDetails","getProjectOutputPath","checkIsRemoteTemplate","getGitHubRepoInfo","debug","initAction","options","context","output","workDir","argType","trace","telemetry","reconfigure","project","organization","defaultConfig","datasetDefault","showDefaultConfigPrompt","dataset","visibility","unattended","detectedFramework","frameworkList","rootPath","isNextJs","slug","remoteTemplateInfo","template","templateToken","name","isAppTemplate","checkFlagsInUnattendedMode","start","log","flags","bare","coupon","env","git","undefined","plan","projectPlan","step","planId","envFilenameDefault","envFilename","user","ensureAuthenticated","success","newProject","projectName","createProjectName","datasetName","displayName","isFirstProject","organizationId","projectId","complete","initNext","nextjsAddConfigFiles","selectedOption","sluggedName","toLowerCase","replaceAll","initFramework","defaults","isPlugin","outputPath","useEnv","Boolean","mcpResult","mode","mcpMode","configuredEditors","detectedEditors","skipped","error","mcpConfigured","alreadyConfiguredEditors","length","label","succeed","envVars","DATASET","PROJECT_ID","filename","framework","sharedParams","hasProjectFlag","alreadyLoggedIn","email","provider","newContext","message","Error","String","loggedInUser"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAA4BC,QAAQ,QAAqC,mBAAkB;AAC3F,SAAQC,UAAU,EAAEC,OAAO,QAAO,sBAAqB;AAEvD,SAAwBC,UAAU,QAAO,qBAAoB;AAC7D,OAAOC,YAAY,sBAAqB;AAExC,SAAQC,oBAAoB,QAAO,+BAA8B;AACjE,SAAQC,UAAU,QAAO,yBAAwB;AACjD,SAAQC,oBAAoB,QAA4B,oCAAmC;AAC3F,SAAQC,qBAAqB,QAAO,gCAA+B;AACnE,SAAQC,kBAAkB,QAAO,mCAAkC;AACnE,SAAQC,eAAe,QAAO,iCAAgC;AAC9D,SAAQC,eAAe,QAAO,6BAA4B;AAC1D,SAAQC,KAAK,QAAO,yBAAwB;AAC5C,SAAQC,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,6BAA6B,QAAO,qCAAoC;AAChF,SAAQC,oBAAoB,QAAO,4BAA2B;AAC9D,SAAQC,qBAAqB,QAAO,iCAAgC;AACpE,SAAQC,OAAO,QAAO,eAAc;AACpC,SAAQC,SAAS,QAAO,iBAAgB;AACxC,SAAQC,aAAa,EAAEC,YAAY,EAAEC,uBAAuB,Q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C,MAAM;QAAO;QAC/CnC,OAAO0B,GAAG,CACR,GAAG3D,WAAW0E,OAAO,CAAC,sBAAsB,EAAEF,KAAK4C,KAAK,CAAC,OAAO,EAAE1G,gBAAgB8D,KAAK6C,QAAQ,GAAG;QAEpG,OAAO;YAAC7C;QAAI;IACd;IAEA,IAAIzC,QAAQe,UAAU,EAAE;QACtB,MAAM,IAAI7B,UACR,gFACA;IAEJ;IAEAmB,MAAMuB,GAAG,CAAC;QAACS,MAAM;IAAO;IAExB,IAAI;QACF,MAAMzD,MAAM;YACVsB;YACAI,WAAWD,MAAMkF,UAAU,CAAC;QAC9B;IACF,EAAE,OAAOhB,OAAO;QACd,MAAMiB,UAAUjB,iBAAiBkB,QAAQlB,MAAMiB,OAAO,GAAGE,OAAOnB;QAChE,MAAM,IAAIrF,UAAU,CAAC,cAAc,EAAEsG,SAAS,EAAE;IAClD;IAEA,MAAMG,eAAe,MAAMrH;IAE3B4B,OAAO0B,GAAG,CACR,GAAG3D,WAAW0E,OAAO,CAAC,sBAAsB,EAAEgD,aAAaN,KAAK,CAAC,OAAO,EAAE1G,gBAAgBgH,aAAaL,QAAQ,GAAG;IAEpH,OAAO;QAAC7C,MAAMkD;IAAY;AAC5B"}
@@ -1,43 +1,34 @@
1
1
  import { styleText } from 'node:util';
2
2
  import { logSymbols } from '@sanity/cli-core/ux';
3
+ import { InitError } from './initError.js';
3
4
  import { getPostInitMCPPrompt } from './initHelpers.js';
4
5
  import { scaffoldAndInstall, selectTemplate } from './scaffoldTemplate.js';
5
- export async function initApp({ autoUpdates, datasetName, defaults, error, git, mcpConfigured, noGit, organizationId, output, outputPath, overwriteFiles, packageManager, projectId, remoteTemplateInfo, sluggedName, template, templateToken, trace, typescript, unattended, workDir }) {
6
+ export async function initApp({ datasetName, defaults, mcpConfigured, options, organizationId, output, outputPath, projectId, remoteTemplateInfo, sluggedName, trace, workDir }) {
6
7
  const { template: resolvedTemplate, templateName, useTypeScript } = await selectTemplate({
8
+ options,
7
9
  remoteTemplateInfo,
8
- template,
9
- trace,
10
- typescript,
11
- unattended
10
+ trace
12
11
  });
13
12
  if (!remoteTemplateInfo && !resolvedTemplate) {
14
- error(`Template "${templateName}" not found`, {
15
- exit: 1
16
- });
13
+ throw new InitError(`Template "${templateName}" not found`, 1);
17
14
  }
18
15
  await scaffoldAndInstall({
19
- autoUpdates,
20
16
  datasetName,
21
17
  defaults,
22
18
  displayName: '',
23
- git,
24
- noGit,
19
+ options,
25
20
  organizationId,
26
21
  output,
27
22
  outputPath,
28
- overwriteFiles,
29
- packageManager,
30
23
  projectId,
31
24
  remoteTemplateInfo,
32
25
  sluggedName,
33
26
  templateName,
34
- templateToken,
35
27
  trace,
36
- unattended,
37
28
  useTypeScript,
38
29
  workDir
39
30
  });
40
- const isCurrentDir = outputPath === process.cwd();
31
+ const isCurrentDir = outputPath === workDir;
41
32
  const goToProjectDir = `\n(${styleText('cyan', `cd ${outputPath}`)} to navigate to your new project directory)`;
42
33
  //output for custom apps here
43
34
  output.log(`${logSymbols.success} ${styleText([
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/init/initApp.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {type Output, type TelemetryUserProperties} from '@sanity/cli-core'\nimport {logSymbols} from '@sanity/cli-core/ux'\nimport {type TelemetryTrace} from '@sanity/telemetry'\n\nimport {type InitStepResult} from '../../telemetry/init.telemetry.js'\nimport {type EditorName} from '../mcp/editorConfigs.js'\nimport {getPostInitMCPPrompt} from './initHelpers.js'\nimport {type RepoInfo} from './remoteTemplate.js'\nimport {scaffoldAndInstall, selectTemplate} from './scaffoldTemplate.js'\n\nexport async function initApp({\n autoUpdates,\n datasetName,\n defaults,\n error,\n git,\n mcpConfigured,\n noGit,\n organizationId,\n output,\n outputPath,\n overwriteFiles,\n packageManager,\n projectId,\n remoteTemplateInfo,\n sluggedName,\n template,\n templateToken,\n trace,\n typescript,\n unattended,\n workDir,\n}: {\n autoUpdates: boolean\n datasetName: string\n defaults: {projectName: string}\n error: Output['error']\n git?: boolean | string\n mcpConfigured: EditorName[]\n noGit?: boolean\n organizationId: string | undefined\n output: Output\n outputPath: string\n overwriteFiles?: boolean\n packageManager?: string\n projectId: string\n remoteTemplateInfo: RepoInfo | undefined\n sluggedName: string\n template?: string\n templateToken?: string\n trace: TelemetryTrace<TelemetryUserProperties, InitStepResult>\n typescript?: boolean\n unattended: boolean\n workDir: string\n}): Promise<void> {\n const {\n template: resolvedTemplate,\n templateName,\n useTypeScript,\n } = await selectTemplate({\n remoteTemplateInfo,\n template,\n trace,\n typescript,\n unattended,\n })\n\n if (!remoteTemplateInfo && !resolvedTemplate) {\n error(`Template \"${templateName}\" not found`, {exit: 1})\n }\n\n await scaffoldAndInstall({\n autoUpdates,\n datasetName,\n defaults,\n displayName: '',\n git,\n noGit,\n organizationId,\n output,\n outputPath,\n overwriteFiles,\n packageManager,\n projectId,\n remoteTemplateInfo,\n sluggedName,\n templateName,\n templateToken,\n trace,\n unattended,\n useTypeScript,\n workDir,\n })\n\n const isCurrentDir = outputPath === process.cwd()\n const goToProjectDir = `\\n(${styleText('cyan', `cd ${outputPath}`)} to navigate to your new project directory)`\n\n //output for custom apps here\n output.log(\n `${logSymbols.success} ${styleText(['green', 'bold'], 'Success!')} Your custom app has been scaffolded.`,\n )\n if (!isCurrentDir) output.log(goToProjectDir)\n\n if (projectId && datasetName) {\n output.log(\n `\\nConfigured with project ${styleText('cyan', projectId)} and dataset ${styleText('cyan', datasetName)}.`,\n )\n output.log(\n 'Edit `src/App.tsx` to change these values or add more project / dataset pairs to your config.',\n )\n } else {\n output.log(\n `\\n${styleText('bold', 'Next')}, configure the project(s) and dataset(s) your app should work with in \\`src/App.tsx\\`.`,\n )\n }\n output.log('\\nRefer to our documentation for a walkthrough:')\n output.log(\n styleText(['blue', 'underline'], 'https://www.sanity.io/docs/app-sdk/sdk-configuration'),\n )\n if (mcpConfigured && mcpConfigured.length > 0) {\n const message = await getPostInitMCPPrompt(mcpConfigured)\n output.log(`\\n${message}`)\n output.log(`\\nLearn more: ${styleText('cyan', 'https://mcp.sanity.io')}`)\n output.log(\n `\\nHave feedback? Tell us in the community: ${styleText('cyan', 'https://www.sanity.io/community/join')}`,\n )\n }\n output.log('\\n')\n output.log(`Other helpful commands:`)\n output.log(`npx sanity docs browse to open the documentation in a browser`)\n output.log(`npx sanity dev to start the development server for your app`)\n output.log(`npx sanity deploy to deploy your app`)\n}\n"],"names":["styleText","logSymbols","getPostInitMCPPrompt","scaffoldAndInstall","selectTemplate","initApp","autoUpdates","datasetName","defaults","error","git","mcpConfigured","noGit","organizationId","output","outputPath","overwriteFiles","packageManager","projectId","remoteTemplateInfo","sluggedName","template","templateToken","trace","typescript","unattended","workDir","resolvedTemplate","templateName","useTypeScript","exit","displayName","isCurrentDir","process","cwd","goToProjectDir","log","success","length","message"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAGnC,SAAQC,UAAU,QAAO,sBAAqB;AAK9C,SAAQC,oBAAoB,QAAO,mBAAkB;AAErD,SAAQC,kBAAkB,EAAEC,cAAc,QAAO,wBAAuB;AAExE,OAAO,eAAeC,QAAQ,EAC5BC,WAAW,EACXC,WAAW,EACXC,QAAQ,EACRC,KAAK,EACLC,GAAG,EACHC,aAAa,EACbC,KAAK,EACLC,cAAc,EACdC,MAAM,EACNC,UAAU,EACVC,cAAc,EACdC,cAAc,EACdC,SAAS,EACTC,kBAAkB,EAClBC,WAAW,EACXC,QAAQ,EACRC,aAAa,EACbC,KAAK,EACLC,UAAU,EACVC,UAAU,EACVC,OAAO,EAuBR;IACC,MAAM,EACJL,UAAUM,gBAAgB,EAC1BC,YAAY,EACZC,aAAa,EACd,GAAG,MAAMzB,eAAe;QACvBe;QACAE;QACAE;QACAC;QACAC;IACF;IAEA,IAAI,CAACN,sBAAsB,CAACQ,kBAAkB;QAC5ClB,MAAM,CAAC,UAAU,EAAEmB,aAAa,WAAW,CAAC,EAAE;YAACE,MAAM;QAAC;IACxD;IAEA,MAAM3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AAC,iEAAiE,CAAC;IAC9EtB,OAAOsB,GAAG,CAAC,CAAC,uEAAuE,CAAC;IACpFtB,OAAOsB,GAAG,CAAC,CAAC,6CAA6C,CAAC;AAC5D"}
1
+ {"version":3,"sources":["../../../src/actions/init/initApp.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {type Output, type TelemetryUserProperties} from '@sanity/cli-core'\nimport {logSymbols} from '@sanity/cli-core/ux'\nimport {type TelemetryTrace} from '@sanity/telemetry'\n\nimport {type InitStepResult} from '../../telemetry/init.telemetry.js'\nimport {type EditorName} from '../mcp/editorConfigs.js'\nimport {InitError} from './initError.js'\nimport {getPostInitMCPPrompt} from './initHelpers.js'\nimport {type RepoInfo} from './remoteTemplate.js'\nimport {scaffoldAndInstall, selectTemplate} from './scaffoldTemplate.js'\nimport {type InitOptions} from './types.js'\n\nexport async function initApp({\n datasetName,\n defaults,\n mcpConfigured,\n options,\n organizationId,\n output,\n outputPath,\n projectId,\n remoteTemplateInfo,\n sluggedName,\n trace,\n workDir,\n}: {\n datasetName: string\n defaults: {projectName: string}\n mcpConfigured: EditorName[]\n options: InitOptions\n organizationId: string | undefined\n output: Output\n outputPath: string\n projectId: string\n remoteTemplateInfo: RepoInfo | undefined\n sluggedName: string\n trace: TelemetryTrace<TelemetryUserProperties, InitStepResult>\n workDir: string\n}): Promise<void> {\n const {\n template: resolvedTemplate,\n templateName,\n useTypeScript,\n } = await selectTemplate({\n options,\n remoteTemplateInfo,\n trace,\n })\n\n if (!remoteTemplateInfo && !resolvedTemplate) {\n throw new InitError(`Template \"${templateName}\" not found`, 1)\n }\n\n await scaffoldAndInstall({\n datasetName,\n defaults,\n displayName: '',\n options,\n organizationId,\n output,\n outputPath,\n projectId,\n remoteTemplateInfo,\n sluggedName,\n templateName,\n trace,\n useTypeScript,\n workDir,\n })\n\n const isCurrentDir = outputPath === workDir\n const goToProjectDir = `\\n(${styleText('cyan', `cd ${outputPath}`)} to navigate to your new project directory)`\n\n //output for custom apps here\n output.log(\n `${logSymbols.success} ${styleText(['green', 'bold'], 'Success!')} Your custom app has been scaffolded.`,\n )\n if (!isCurrentDir) output.log(goToProjectDir)\n\n if (projectId && datasetName) {\n output.log(\n `\\nConfigured with project ${styleText('cyan', projectId)} and dataset ${styleText('cyan', datasetName)}.`,\n )\n output.log(\n 'Edit `src/App.tsx` to change these values or add more project / dataset pairs to your config.',\n )\n } else {\n output.log(\n `\\n${styleText('bold', 'Next')}, configure the project(s) and dataset(s) your app should work with in \\`src/App.tsx\\`.`,\n )\n }\n output.log('\\nRefer to our documentation for a walkthrough:')\n output.log(\n styleText(['blue', 'underline'], 'https://www.sanity.io/docs/app-sdk/sdk-configuration'),\n )\n if (mcpConfigured && mcpConfigured.length > 0) {\n const message = await getPostInitMCPPrompt(mcpConfigured)\n output.log(`\\n${message}`)\n output.log(`\\nLearn more: ${styleText('cyan', 'https://mcp.sanity.io')}`)\n output.log(\n `\\nHave feedback? Tell us in the community: ${styleText('cyan', 'https://www.sanity.io/community/join')}`,\n )\n }\n output.log('\\n')\n output.log(`Other helpful commands:`)\n output.log(`npx sanity docs browse to open the documentation in a browser`)\n output.log(`npx sanity dev to start the development server for your app`)\n output.log(`npx sanity deploy to deploy your app`)\n}\n"],"names":["styleText","logSymbols","InitError","getPostInitMCPPrompt","scaffoldAndInstall","selectTemplate","initApp","datasetName","defaults","mcpConfigured","options","organizationId","output","outputPath","projectId","remoteTemplateInfo","sluggedName","trace","workDir","template","resolvedTemplate","templateName","useTypeScript","displayName","isCurrentDir","goToProjectDir","log","success","length","message"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAGnC,SAAQC,UAAU,QAAO,sBAAqB;AAK9C,SAAQC,SAAS,QAAO,iBAAgB;AACxC,SAAQC,oBAAoB,QAAO,mBAAkB;AAErD,SAAQC,kBAAkB,EAAEC,cAAc,QAAO,wBAAuB;AAGxE,OAAO,eAAeC,QAAQ,EAC5BC,WAAW,EACXC,QAAQ,EACRC,aAAa,EACbC,OAA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