@sanity/cli 7.15.0 → 7.16.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 (138) hide show
  1. package/README.md +88 -1
  2. package/dist/actions/build/shouldAutoUpdate.js +28 -5
  3. package/dist/actions/build/shouldAutoUpdate.js.map +1 -1
  4. package/dist/actions/deploy/deployApp.js +4 -8
  5. package/dist/actions/deploy/deployApp.js.map +1 -1
  6. package/dist/actions/deploy/deployChecks.js +49 -31
  7. package/dist/actions/deploy/deployChecks.js.map +1 -1
  8. package/dist/actions/deploy/deployRunner.js +1 -1
  9. package/dist/actions/deploy/deployRunner.js.map +1 -1
  10. package/dist/actions/deploy/deployStudio.js +12 -10
  11. package/dist/actions/deploy/deployStudio.js.map +1 -1
  12. package/dist/actions/deploy/deploymentPlan.js +2 -2
  13. package/dist/actions/deploy/deploymentPlan.js.map +1 -1
  14. package/dist/actions/deploy/resolveDeployTarget.js +13 -13
  15. package/dist/actions/deploy/resolveDeployTarget.js.map +1 -1
  16. package/dist/actions/init/bootstrapLocalTemplate.js +2 -3
  17. package/dist/actions/init/bootstrapLocalTemplate.js.map +1 -1
  18. package/dist/actions/init/createAppCliConfig.js.map +1 -1
  19. package/dist/actions/init/createCliConfig.js.map +1 -1
  20. package/dist/actions/init/initNextJs.js +1 -1
  21. package/dist/actions/init/initNextJs.js.map +1 -1
  22. package/dist/actions/init/initStudio.js +10 -6
  23. package/dist/actions/init/initStudio.js.map +1 -1
  24. package/dist/actions/init/templates/appSanityUi.js +1 -1
  25. package/dist/actions/init/templates/appSanityUi.js.map +1 -1
  26. package/dist/actions/init/templates/getStarted.js +2 -2
  27. package/dist/actions/init/templates/getStarted.js.map +1 -1
  28. package/dist/actions/init/templates/nextjs/schemaTypes/blog.js +4 -4
  29. package/dist/actions/init/templates/nextjs/schemaTypes/blog.js.map +1 -1
  30. package/dist/actions/init/templates/shopify.js +2 -2
  31. package/dist/actions/init/templates/shopify.js.map +1 -1
  32. package/dist/actions/init/templates/shopifyOnline.js +2 -2
  33. package/dist/actions/init/templates/shopifyOnline.js.map +1 -1
  34. package/dist/actions/manifest/extractCoreAppManifest.js +7 -7
  35. package/dist/actions/manifest/extractCoreAppManifest.js.map +1 -1
  36. package/dist/actions/scaffold/createFrontend.js +107 -0
  37. package/dist/actions/scaffold/createFrontend.js.map +1 -0
  38. package/dist/actions/scaffold/scaffoldProject.js +202 -0
  39. package/dist/actions/scaffold/scaffoldProject.js.map +1 -0
  40. package/dist/actions/telemetry/resolveConsent.js +4 -2
  41. package/dist/actions/telemetry/resolveConsent.js.map +1 -1
  42. package/dist/commands/backups/list.js +1 -1
  43. package/dist/commands/backups/list.js.map +1 -1
  44. package/dist/commands/datasets/copy.js +5 -3
  45. package/dist/commands/datasets/copy.js.map +1 -1
  46. package/dist/commands/documents/query.js +5 -4
  47. package/dist/commands/documents/query.js.map +1 -1
  48. package/dist/commands/migrations/list.js +1 -1
  49. package/dist/commands/migrations/list.js.map +1 -1
  50. package/dist/commands/migrations/run.js +1 -1
  51. package/dist/commands/migrations/run.js.map +1 -1
  52. package/dist/commands/new.js +309 -0
  53. package/dist/commands/new.js.map +1 -0
  54. package/dist/commands/organizations/list.js +1 -1
  55. package/dist/commands/organizations/list.js.map +1 -1
  56. package/dist/commands/projects/unclaimed.js +205 -0
  57. package/dist/commands/projects/unclaimed.js.map +1 -0
  58. package/dist/commands/tokens/list.js +1 -1
  59. package/dist/commands/tokens/list.js.map +1 -1
  60. package/dist/commands/users/list.js +5 -1
  61. package/dist/commands/users/list.js.map +1 -1
  62. package/dist/exports/invokeSanityCli/commandPolicies/mcpPolicy.js +4 -0
  63. package/dist/exports/invokeSanityCli/commandPolicies/mcpPolicy.js.map +1 -1
  64. package/dist/exports/invokeSanityCli/index.d.ts +5 -9
  65. package/dist/exports/invokeSanityCli/index.js +47 -20
  66. package/dist/exports/invokeSanityCli/index.js.map +1 -1
  67. package/dist/exports/runtime.d.ts +12 -0
  68. package/dist/exports/runtime.js.map +1 -1
  69. package/dist/services/mintProject.js +91 -0
  70. package/dist/services/mintProject.js.map +1 -0
  71. package/dist/services/projects.js +19 -0
  72. package/dist/services/projects.js.map +1 -1
  73. package/dist/services/telemetry.js +4 -0
  74. package/dist/services/telemetry.js.map +1 -1
  75. package/dist/util/formatClaimDeadline.js +15 -0
  76. package/dist/util/formatClaimDeadline.js.map +1 -0
  77. package/dist/util/mintProjectConstants.js +6 -0
  78. package/dist/util/mintProjectConstants.js.map +1 -0
  79. package/dist/util/newCommandSplash.js +27 -0
  80. package/dist/util/newCommandSplash.js.map +1 -0
  81. package/dist/util/packageManager/installPackages.js +57 -28
  82. package/dist/util/packageManager/installPackages.js.map +1 -1
  83. package/dist/util/unclaimedProjects.js +105 -0
  84. package/dist/util/unclaimedProjects.js.map +1 -0
  85. package/oclif.manifest.json +150 -41
  86. package/package.json +7 -7
  87. package/templates/get-started/plugins/sanity-plugin-tutorial/GetStartedTutorial.tsx +1 -1
  88. package/templates/shopify/components/inputs/CollectionHidden.tsx +1 -1
  89. package/templates/shopify/components/inputs/ProductHidden.tsx +1 -1
  90. package/templates/shopify/components/inputs/ProductVariantHidden.tsx +1 -1
  91. package/templates/shopify/components/inputs/ProxyString.tsx +1 -1
  92. package/templates/shopify/components/media/ShopifyDocumentStatus.tsx +3 -1
  93. package/templates/shopify/constants.ts +3 -1
  94. package/templates/shopify/plugins/customDocumentActions/shopifyDelete.tsx +1 -1
  95. package/templates/shopify/plugins/customDocumentActions/shopifyLink.ts +1 -1
  96. package/templates/shopify/schemaTypes/documents/collection.tsx +1 -1
  97. package/templates/shopify/schemaTypes/documents/colorTheme.tsx +1 -1
  98. package/templates/shopify/schemaTypes/documents/page.ts +1 -1
  99. package/templates/shopify/schemaTypes/documents/product.tsx +1 -1
  100. package/templates/shopify/schemaTypes/documents/productVariant.tsx +1 -1
  101. package/templates/shopify/schemaTypes/objects/collection/collectionGroupType.ts +1 -1
  102. package/templates/shopify/schemaTypes/objects/hotspot/imageWithProductHotspotsType.ts +1 -1
  103. package/templates/shopify/schemaTypes/objects/link/linkEmailType.tsx +1 -1
  104. package/templates/shopify/schemaTypes/objects/link/linkExternalType.tsx +1 -1
  105. package/templates/shopify/schemaTypes/objects/link/linkInternalType.tsx +1 -1
  106. package/templates/shopify/schemaTypes/objects/link/linkProductType.tsx +1 -1
  107. package/templates/shopify/schemaTypes/objects/module/accordionType.ts +1 -1
  108. package/templates/shopify/schemaTypes/objects/module/callToActionType.tsx +2 -1
  109. package/templates/shopify/schemaTypes/objects/module/calloutType.ts +1 -1
  110. package/templates/shopify/schemaTypes/objects/module/collectionReferenceType.tsx +1 -1
  111. package/templates/shopify/schemaTypes/objects/module/gridType.ts +1 -1
  112. package/templates/shopify/schemaTypes/objects/module/imageFeatureType.ts +1 -1
  113. package/templates/shopify/schemaTypes/objects/module/imageFeaturesType.tsx +1 -1
  114. package/templates/shopify/schemaTypes/objects/module/instagramType.ts +1 -1
  115. package/templates/shopify/schemaTypes/objects/module/productFeaturesType.tsx +1 -1
  116. package/templates/shopify/schemaTypes/objects/module/productReferenceType.tsx +1 -1
  117. package/templates/shopify/schemaTypes/objects/shopify/collectionRuleType.tsx +1 -1
  118. package/templates/shopify/schemaTypes/objects/shopify/optionType.tsx +1 -1
  119. package/templates/shopify/schemaTypes/objects/shopify/productWithVariantType.tsx +1 -1
  120. package/templates/shopify/schemaTypes/singletons/homeType.ts +1 -1
  121. package/templates/shopify/schemaTypes/singletons/settingsType.ts +5 -1
  122. package/templates/shopify/structure/pageStructure.ts +1 -1
  123. package/templates/shopify/structure/productStructure.ts +1 -1
  124. package/templates/shopify-online-storefront/components/inputs/CollectionHidden.tsx +1 -1
  125. package/templates/shopify-online-storefront/components/inputs/ProductHidden.tsx +1 -1
  126. package/templates/shopify-online-storefront/components/inputs/ProductVariantHidden.tsx +1 -1
  127. package/templates/shopify-online-storefront/components/inputs/ProxyString.tsx +1 -1
  128. package/templates/shopify-online-storefront/components/media/ShopifyDocumentStatus.tsx +3 -1
  129. package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/shopifyDelete.tsx +1 -1
  130. package/templates/shopify-online-storefront/plugins/shopifyDocumentActions/shopifyLink.ts +1 -1
  131. package/templates/shopify-online-storefront/schemaTypes/documents/collection.tsx +1 -1
  132. package/templates/shopify-online-storefront/schemaTypes/documents/product.tsx +1 -1
  133. package/templates/shopify-online-storefront/schemaTypes/documents/productVariant.tsx +1 -1
  134. package/templates/shopify-online-storefront/schemaTypes/objects/accordion.ts +1 -1
  135. package/templates/shopify-online-storefront/schemaTypes/objects/callout.ts +1 -1
  136. package/templates/shopify-online-storefront/schemaTypes/objects/option.ts +1 -1
  137. package/templates/shopify-online-storefront/schemaTypes/objects/shopifyCollectionRule.tsx +1 -1
  138. package/templates/shopify-online-storefront/structure/productStructure.ts +1 -1
@@ -3,6 +3,7 @@ import path from 'node:path';
3
3
  import { styleText } from 'node:util';
4
4
  import { subdebug } from '@sanity/cli-core';
5
5
  import { spinner } from '@sanity/cli-core/ux';
6
+ import { toAppSlug } from '@sanity/workbench-cli/init';
6
7
  import deburr from 'lodash-es/deburr.js';
7
8
  import { copy } from '../../util/copy.js';
8
9
  import { resolveLatestVersions } from '../../util/resolveLatestVersions.js';
@@ -96,7 +97,7 @@ export async function bootstrapLocalTemplate(opts) {
96
97
  // project name. Fall back to a constant when the source slugifies to
97
98
  // nothing (e.g. a fully non-latin name): an empty `slug` fails app config
98
99
  // validation, which is exactly what pre-filling it is meant to avoid.
99
- const slug = (isAppTemplate ? packageJsonName : slugify(title)) || 'sanity-app';
100
+ const slug = toAppSlug(isAppTemplate ? packageJsonName : title) ?? 'sanity-app';
100
101
  // Now create a package manifest (`package.json`) with the merged dependencies
101
102
  spin = spinner('Creating default project files').start();
102
103
  const packageManifest = createPackageManifest({
@@ -116,7 +117,6 @@ export async function bootstrapLocalTemplate(opts) {
116
117
  const cliConfig = isAppTemplate ? createAppCliConfig({
117
118
  entry: template.entry,
118
119
  isWorkbenchApp: variables.workbench,
119
- name: packageJsonName,
120
120
  organizationId: variables.organizationId,
121
121
  slug,
122
122
  title
@@ -124,7 +124,6 @@ export async function bootstrapLocalTemplate(opts) {
124
124
  autoUpdates: variables.autoUpdates,
125
125
  dataset: variables.dataset,
126
126
  isWorkbenchApp: variables.workbench,
127
- name: packageJsonName,
128
127
  organizationId: variables.organizationId,
129
128
  projectId: variables.projectId,
130
129
  slug,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/init/bootstrapLocalTemplate.ts"],"sourcesContent":["import fs from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {Output, subdebug} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport deburr from 'lodash-es/deburr.js'\n\nimport {copy} from '../../util/copy.js'\nimport {resolveLatestVersions} from '../../util/resolveLatestVersions.js'\nimport {createAppCliConfig} from './createAppCliConfig.js'\nimport {createCliConfig} from './createCliConfig.js'\nimport {createPackageManifest} from './createPackageManifest.js'\nimport {createStudioConfig, type GenerateConfigOptions} from './createStudioConfig.js'\nimport {determineAppTemplate} from './determineAppTemplate.js'\nimport {processTemplate} from './processTemplate.js'\nimport {sdkAppDependencies} from './sdkAppDependencies.js'\nimport {studioDependencies} from './studioDependencies.js'\nimport templates from './templates/index.js'\nimport {type ProjectTemplate} from './types.js'\nimport {updateInitialTemplateMetadata} from './updateInitialTemplateMetadata.js'\n\nconst debug = subdebug('init:bootstrapRemoteTemplate')\n\ninterface BootstrapLocalOptions {\n output: Output\n outputPath: string\n packageName: string\n templateName: string\n useTypeScript: boolean\n variables: GenerateConfigOptions['variables']\n\n overwriteFiles?: boolean\n}\n\nexport async function bootstrapLocalTemplate(\n opts: BootstrapLocalOptions,\n): Promise<ProjectTemplate> {\n const {output, outputPath, packageName, templateName, useTypeScript, variables} = opts\n // packages/@sanity/cli/src/actions/init/ -> packages/@sanity/cli/src/action -> packages/@sanity/cli/src/\n const cliRoot = path.resolve(import.meta.dirname, '../../..')\n const templatesDir = path.join(cliRoot, 'templates')\n const sourceDir = path.join(templatesDir, templateName)\n const sharedDir = path.join(templatesDir, 'shared')\n const isAppTemplate = determineAppTemplate(templateName)\n\n // Check that we have a template info file (dependencies, plugins etc)\n const template = templates[templateName]\n if (!template) {\n throw new Error(`Template \"${templateName}\" not defined`)\n }\n\n // Copy template files\n debug('Copying files from template \"%s\" to \"%s\"', templateName, outputPath)\n let spin = spinner('Bootstrapping files from template').start()\n\n debug(`Copying template from : ${sourceDir}`)\n await copy(sourceDir, outputPath, {\n rename: useTypeScript ? toTypeScriptPath : undefined,\n })\n debug(`Copying shared template code from : ${sharedDir}`)\n await copy(path.join(sharedDir, 'gitignore.txt'), outputPath, {rename: () => '.gitignore'})\n\n if (useTypeScript) {\n await fs.copyFile(path.join(sharedDir, 'tsconfig.json'), path.join(outputPath, 'tsconfig.json'))\n }\n\n spin.succeed()\n\n if (isAppTemplate) {\n const appEntryPath = path.join(outputPath, 'src', 'App.tsx')\n const raw = await fs.readFile(appEntryPath, 'utf8')\n const rendered = processTemplate({\n template: raw,\n variables: {\n dataset: variables.dataset ?? '',\n projectId: variables.projectId ?? '',\n },\n })\n await fs.writeFile(appEntryPath, rendered)\n }\n\n // Merge global and template-specific plugins and dependencies\n\n // Resolve latest versions of Sanity-dependencies\n spin = spinner('Resolving latest module versions').start()\n const dependencyVersions = await resolveLatestVersions({\n ...(isAppTemplate ? sdkAppDependencies.dependencies : studioDependencies.dependencies),\n ...(isAppTemplate ? sdkAppDependencies.devDependencies : studioDependencies.devDependencies),\n ...template.dependencies,\n ...template.devDependencies,\n })\n spin.succeed()\n\n // Use the resolved version for the given dependency\n const dependencies: Record<string, string> = {}\n for (const dependency of Object.keys({\n ...(isAppTemplate ? sdkAppDependencies.dependencies : studioDependencies.dependencies),\n ...template.dependencies,\n })) {\n dependencies[dependency] = dependencyVersions[dependency]\n }\n\n const devDependencies: Record<string, string> = {}\n for (const dependency of Object.keys({\n ...(isAppTemplate ? sdkAppDependencies.devDependencies : studioDependencies.devDependencies),\n ...template.devDependencies,\n })) {\n devDependencies[dependency] = dependencyVersions[dependency]\n }\n\n let packageJsonName: string = packageName\n\n /**\n * Currently app init doesn't ask for a name, so we use the last part of the path\n */\n if (isAppTemplate) {\n packageJsonName = slugify(path.basename(outputPath))\n }\n\n const title = variables.projectName || packageJsonName\n // Default the workbench app `slug` (the hostname the application is created\n // at on deploy). App init never asks for a name (`variables.projectName` is\n // just the cwd basename there), so apps follow their identity — the\n // output-path basename (`packageJsonName`) — while studios slug the entered\n // project name. Fall back to a constant when the source slugifies to\n // nothing (e.g. a fully non-latin name): an empty `slug` fails app config\n // validation, which is exactly what pre-filling it is meant to avoid.\n const slug = (isAppTemplate ? packageJsonName : slugify(title)) || 'sanity-app'\n\n // Now create a package manifest (`package.json`) with the merged dependencies\n spin = spinner('Creating default project files').start()\n const packageManifest = createPackageManifest({\n dependencies,\n devDependencies,\n isAppTemplate,\n name: packageJsonName,\n scripts: template.scripts,\n type: template.type,\n })\n\n // ...and a studio config (`sanity.config.[ts|js]`)\n const studioConfig = createStudioConfig({\n template: template.configTemplate,\n variables,\n })\n\n // ...and a CLI config (`sanity.cli.[ts|js]`)\n const cliConfig = isAppTemplate\n ? createAppCliConfig({\n entry: template.entry!,\n isWorkbenchApp: variables.workbench,\n name: packageJsonName,\n organizationId: variables.organizationId,\n slug,\n title,\n })\n : createCliConfig({\n autoUpdates: variables.autoUpdates,\n dataset: variables.dataset,\n isWorkbenchApp: variables.workbench,\n name: packageJsonName,\n organizationId: variables.organizationId,\n projectId: variables.projectId,\n slug,\n title,\n })\n\n // Write non-template files to disc\n const codeExt = useTypeScript ? 'ts' : 'js'\n await Promise.all(\n [\n isAppTemplate\n ? Promise.resolve(null)\n : writeFileIfNotExists(`sanity.config.${codeExt}`, studioConfig),\n writeFileIfNotExists(`sanity.cli.${codeExt}`, cliConfig),\n writeFileIfNotExists('package.json', packageManifest),\n\n writeFileIfNotExists(\n 'eslint.config.mjs',\n `import studio from '@sanity/eslint-config-studio'\\n\\nexport default [...studio]\\n`,\n ),\n ].filter(Boolean),\n )\n\n debug('Updating initial template metadata')\n if (variables.projectId) {\n await updateInitialTemplateMetadata(variables.projectId, `cli-${templateName}`)\n }\n\n // Finish up by providing init process with template-specific info\n spin.succeed()\n return template\n\n async function writeFileIfNotExists(fileName: string, content: string): Promise<void> {\n const filePath = path.join(outputPath, fileName)\n\n if (opts.overwriteFiles) {\n // If overwrite is enabled, just write the file\n await fs.writeFile(filePath, content)\n return\n }\n\n try {\n await fs.writeFile(filePath, content, {flag: 'wx'})\n } catch (err) {\n if (err.code === 'EEXIST') {\n output.warn(`\\n${styleText('yellow', '⚠')} File \"${filePath}\" already exists, skipping`)\n } else {\n throw err\n }\n }\n }\n}\n\nfunction toTypeScriptPath(originalPath: string): string {\n return originalPath.replace(/\\.js$/, '.ts')\n}\n\n/** Lowercase, deburred, spaces to hyphens, everything else stripped. */\nfunction slugify(value: string): string {\n return deburr(value.toLowerCase())\n .replaceAll(/\\s+/g, '-')\n .replaceAll(/[^a-z0-9-]/g, '')\n}\n"],"names":["fs","path","styleText","subdebug","spinner","deburr","copy","resolveLatestVersions","createAppCliConfig","createCliConfig","createPackageManifest","createStudioConfig","determineAppTemplate","processTemplate","sdkAppDependencies","studioDependencies","templates","updateInitialTemplateMetadata","debug","bootstrapLocalTemplate","opts","output","outputPath","packageName","templateName","useTypeScript","variables","cliRoot","resolve","dirname","templatesDir","join","sourceDir","sharedDir","isAppTemplate","template","Error","spin","start","rename","toTypeScriptPath","undefined","copyFile","succeed","appEntryPath","raw","readFile","rendered","dataset","projectId","writeFile","dependencyVersions","dependencies","devDependencies","dependency","Object","keys","packageJsonName","slugify","basename","title","projectName","slug","packageManifest","name","scripts","type","studioConfig","configTemplate","cliConfig","entry","isWorkbenchApp","workbench","organizationId","autoUpdates","codeExt","Promise","all","writeFileIfNotExists","filter","Boolean","fileName","content","filePath","overwriteFiles","flag","err","code","warn","originalPath","replace","value","toLowerCase","replaceAll"],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iC,KAAa;IAC5B,OAAOtF,OAAOsF,MAAMC,WAAW,IAC5BC,UAAU,CAAC,QAAQ,KACnBA,UAAU,CAAC,eAAe;AAC/B"}
1
+ {"version":3,"sources":["../../../src/actions/init/bootstrapLocalTemplate.ts"],"sourcesContent":["import fs from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {Output, subdebug} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {toAppSlug} from '@sanity/workbench-cli/init'\nimport deburr from 'lodash-es/deburr.js'\n\nimport {copy} from '../../util/copy.js'\nimport {resolveLatestVersions} from '../../util/resolveLatestVersions.js'\nimport {createAppCliConfig} from './createAppCliConfig.js'\nimport {createCliConfig} from './createCliConfig.js'\nimport {createPackageManifest} from './createPackageManifest.js'\nimport {createStudioConfig, type GenerateConfigOptions} from './createStudioConfig.js'\nimport {determineAppTemplate} from './determineAppTemplate.js'\nimport {processTemplate} from './processTemplate.js'\nimport {sdkAppDependencies} from './sdkAppDependencies.js'\nimport {studioDependencies} from './studioDependencies.js'\nimport templates from './templates/index.js'\nimport {type ProjectTemplate} from './types.js'\nimport {updateInitialTemplateMetadata} from './updateInitialTemplateMetadata.js'\n\nconst debug = subdebug('init:bootstrapRemoteTemplate')\n\ninterface BootstrapLocalOptions {\n output: Output\n outputPath: string\n packageName: string\n templateName: string\n useTypeScript: boolean\n variables: GenerateConfigOptions['variables']\n\n overwriteFiles?: boolean\n}\n\nexport async function bootstrapLocalTemplate(\n opts: BootstrapLocalOptions,\n): Promise<ProjectTemplate> {\n const {output, outputPath, packageName, templateName, useTypeScript, variables} = opts\n // packages/@sanity/cli/src/actions/init/ -> packages/@sanity/cli/src/action -> packages/@sanity/cli/src/\n const cliRoot = path.resolve(import.meta.dirname, '../../..')\n const templatesDir = path.join(cliRoot, 'templates')\n const sourceDir = path.join(templatesDir, templateName)\n const sharedDir = path.join(templatesDir, 'shared')\n const isAppTemplate = determineAppTemplate(templateName)\n\n // Check that we have a template info file (dependencies, plugins etc)\n const template = templates[templateName]\n if (!template) {\n throw new Error(`Template \"${templateName}\" not defined`)\n }\n\n // Copy template files\n debug('Copying files from template \"%s\" to \"%s\"', templateName, outputPath)\n let spin = spinner('Bootstrapping files from template').start()\n\n debug(`Copying template from : ${sourceDir}`)\n await copy(sourceDir, outputPath, {\n rename: useTypeScript ? toTypeScriptPath : undefined,\n })\n debug(`Copying shared template code from : ${sharedDir}`)\n await copy(path.join(sharedDir, 'gitignore.txt'), outputPath, {rename: () => '.gitignore'})\n\n if (useTypeScript) {\n await fs.copyFile(path.join(sharedDir, 'tsconfig.json'), path.join(outputPath, 'tsconfig.json'))\n }\n\n spin.succeed()\n\n if (isAppTemplate) {\n const appEntryPath = path.join(outputPath, 'src', 'App.tsx')\n const raw = await fs.readFile(appEntryPath, 'utf8')\n const rendered = processTemplate({\n template: raw,\n variables: {\n dataset: variables.dataset ?? '',\n projectId: variables.projectId ?? '',\n },\n })\n await fs.writeFile(appEntryPath, rendered)\n }\n\n // Merge global and template-specific plugins and dependencies\n\n // Resolve latest versions of Sanity-dependencies\n spin = spinner('Resolving latest module versions').start()\n const dependencyVersions = await resolveLatestVersions({\n ...(isAppTemplate ? sdkAppDependencies.dependencies : studioDependencies.dependencies),\n ...(isAppTemplate ? sdkAppDependencies.devDependencies : studioDependencies.devDependencies),\n ...template.dependencies,\n ...template.devDependencies,\n })\n spin.succeed()\n\n // Use the resolved version for the given dependency\n const dependencies: Record<string, string> = {}\n for (const dependency of Object.keys({\n ...(isAppTemplate ? sdkAppDependencies.dependencies : studioDependencies.dependencies),\n ...template.dependencies,\n })) {\n dependencies[dependency] = dependencyVersions[dependency]\n }\n\n const devDependencies: Record<string, string> = {}\n for (const dependency of Object.keys({\n ...(isAppTemplate ? sdkAppDependencies.devDependencies : studioDependencies.devDependencies),\n ...template.devDependencies,\n })) {\n devDependencies[dependency] = dependencyVersions[dependency]\n }\n\n let packageJsonName: string = packageName\n\n /**\n * Currently app init doesn't ask for a name, so we use the last part of the path\n */\n if (isAppTemplate) {\n packageJsonName = slugify(path.basename(outputPath))\n }\n\n const title = variables.projectName || packageJsonName\n // Default the workbench app `slug` (the hostname the application is created\n // at on deploy). App init never asks for a name (`variables.projectName` is\n // just the cwd basename there), so apps follow their identity — the\n // output-path basename (`packageJsonName`) — while studios slug the entered\n // project name. Fall back to a constant when the source slugifies to\n // nothing (e.g. a fully non-latin name): an empty `slug` fails app config\n // validation, which is exactly what pre-filling it is meant to avoid.\n const slug = toAppSlug(isAppTemplate ? packageJsonName : title) ?? 'sanity-app'\n\n // Now create a package manifest (`package.json`) with the merged dependencies\n spin = spinner('Creating default project files').start()\n const packageManifest = createPackageManifest({\n dependencies,\n devDependencies,\n isAppTemplate,\n name: packageJsonName,\n scripts: template.scripts,\n type: template.type,\n })\n\n // ...and a studio config (`sanity.config.[ts|js]`)\n const studioConfig = createStudioConfig({\n template: template.configTemplate,\n variables,\n })\n\n // ...and a CLI config (`sanity.cli.[ts|js]`)\n const cliConfig = isAppTemplate\n ? createAppCliConfig({\n entry: template.entry!,\n isWorkbenchApp: variables.workbench,\n organizationId: variables.organizationId,\n slug,\n title,\n })\n : createCliConfig({\n autoUpdates: variables.autoUpdates,\n dataset: variables.dataset,\n isWorkbenchApp: variables.workbench,\n organizationId: variables.organizationId,\n projectId: variables.projectId,\n slug,\n title,\n })\n\n // Write non-template files to disc\n const codeExt = useTypeScript ? 'ts' : 'js'\n await Promise.all(\n [\n isAppTemplate\n ? Promise.resolve(null)\n : writeFileIfNotExists(`sanity.config.${codeExt}`, studioConfig),\n writeFileIfNotExists(`sanity.cli.${codeExt}`, cliConfig),\n writeFileIfNotExists('package.json', packageManifest),\n\n writeFileIfNotExists(\n 'eslint.config.mjs',\n `import studio from '@sanity/eslint-config-studio'\\n\\nexport default [...studio]\\n`,\n ),\n ].filter(Boolean),\n )\n\n debug('Updating initial template metadata')\n if (variables.projectId) {\n await updateInitialTemplateMetadata(variables.projectId, `cli-${templateName}`)\n }\n\n // Finish up by providing init process with template-specific info\n spin.succeed()\n return template\n\n async function writeFileIfNotExists(fileName: string, content: string): Promise<void> {\n const filePath = path.join(outputPath, fileName)\n\n if (opts.overwriteFiles) {\n // If overwrite is enabled, just write the file\n await fs.writeFile(filePath, content)\n return\n }\n\n try {\n await fs.writeFile(filePath, content, {flag: 'wx'})\n } catch (err) {\n if (err.code === 'EEXIST') {\n output.warn(`\\n${styleText('yellow', '⚠')} File \"${filePath}\" already exists, skipping`)\n } else {\n throw err\n }\n }\n }\n}\n\nfunction toTypeScriptPath(originalPath: string): string {\n return originalPath.replace(/\\.js$/, '.ts')\n}\n\n/** Lowercase, deburred, spaces to hyphens, everything else stripped. */\nfunction slugify(value: string): string {\n return deburr(value.toLowerCase())\n .replaceAll(/\\s+/g, '-')\n .replaceAll(/[^a-z0-9-]/g, '')\n}\n"],"names":["fs","path","styleText","subdebug","spinner","toAppSlug","deburr","copy","resolveLatestVersions","createAppCliConfig","createCliConfig","createPackageManifest","createStudioConfig","determineAppTemplate","processTemplate","sdkAppDependencies","studioDependencies","templates","updateInitialTemplateMetadata","debug","bootstrapLocalTemplate","opts","output","outputPath","packageName","templateName","useTypeScript","variables","cliRoot","resolve","dirname","templatesDir","join","sourceDir","sharedDir","isAppTemplate","template","Error","spin","start","rename","toTypeScriptPath","undefined","copyFile","succeed","appEntryPath","raw","readFile","rendered","dataset","projectId","writeFile","dependencyVersions","dependencies","devDependencies","dependency","Object","keys","packageJsonName","slugify","basename","title","projectName","slug","packageManifest","name","scripts","type","studioConfig","configTemplate","cliConfig","entry","isWorkbenchApp","workbench","organizationId","autoUpdates","codeExt","Promise","all","writeFileIfNotExists","filter","Boolean","fileName","content","filePath","overwriteFiles","flag","err","code","warn","originalPath","replace","value","toLowerCase","replaceAll"],"mappings":"AAAA,OAAOA,QAAQ,mBAAkB;AACjC,OAAOC,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAgBC,QAAQ,QAAO,mBAAkB;AACj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../src/actions/init/createAppCliConfig.ts"],"sourcesContent":["import {workbenchAppConfigTemplate} from '@sanity/workbench-cli/init'\n\nimport {processTemplate} from './processTemplate.js'\n\nconst defaultAppTemplate = `\nimport {defineCliConfig} from 'sanity/cli'\n\nexport default defineCliConfig({\n app: {\n organizationId: '%organizationId%',\n entry: '%entry%',\n },\n})\n`\n\ninterface GenerateCliConfigOptions {\n entry: string\n isWorkbenchApp: boolean\n name: string\n slug: string\n title: string\n\n organizationId?: string\n}\n\nexport function createAppCliConfig(options: GenerateCliConfigOptions): string {\n const {isWorkbenchApp, ...variables} = options\n return processTemplate({\n includeBooleanTransform: true,\n template: isWorkbenchApp ? workbenchAppConfigTemplate : defaultAppTemplate,\n variables,\n })\n}\n"],"names":["workbenchAppConfigTemplate","processTemplate","defaultAppTemplate","createAppCliConfig","options","isWorkbenchApp","variables","includeBooleanTransform","template"],"mappings":"AAAA,SAAQA,0BAA0B,QAAO,6BAA4B;AAErE,SAAQC,eAAe,QAAO,uBAAsB;AAEpD,MAAMC,qBAAqB,CAAC;;;;;;;;;AAS5B,CAAC;AAYD,OAAO,SAASC,mBAAmBC,OAAiC;IAClE,MAAM,EAACC,cAAc,EAAE,GAAGC,WAAU,GAAGF;IACvC,OAAOH,gBAAgB;QACrBM,yBAAyB;QACzBC,UAAUH,iBAAiBL,6BAA6BE;QACxDI;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/init/createAppCliConfig.ts"],"sourcesContent":["import {workbenchAppConfigTemplate} from '@sanity/workbench-cli/init'\n\nimport {processTemplate} from './processTemplate.js'\n\nconst defaultAppTemplate = `\nimport {defineCliConfig} from 'sanity/cli'\n\nexport default defineCliConfig({\n app: {\n organizationId: '%organizationId%',\n entry: '%entry%',\n },\n})\n`\n\ninterface GenerateCliConfigOptions {\n entry: string\n isWorkbenchApp: boolean\n slug: string\n title: string\n\n organizationId?: string\n}\n\nexport function createAppCliConfig(options: GenerateCliConfigOptions): string {\n const {isWorkbenchApp, ...variables} = options\n return processTemplate({\n includeBooleanTransform: true,\n template: isWorkbenchApp ? workbenchAppConfigTemplate : defaultAppTemplate,\n variables,\n })\n}\n"],"names":["workbenchAppConfigTemplate","processTemplate","defaultAppTemplate","createAppCliConfig","options","isWorkbenchApp","variables","includeBooleanTransform","template"],"mappings":"AAAA,SAAQA,0BAA0B,QAAO,6BAA4B;AAErE,SAAQC,eAAe,QAAO,uBAAsB;AAEpD,MAAMC,qBAAqB,CAAC;;;;;;;;;AAS5B,CAAC;AAWD,OAAO,SAASC,mBAAmBC,OAAiC;IAClE,MAAM,EAACC,cAAc,EAAE,GAAGC,WAAU,GAAGF;IACvC,OAAOH,gBAAgB;QACrBM,yBAAyB;QACzBC,UAAUH,iBAAiBL,6BAA6BE;QACxDI;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/init/createCliConfig.ts"],"sourcesContent":["import {workbenchStudioConfigTemplate} from '@sanity/workbench-cli/init'\n\nimport {processTemplate} from './processTemplate.js'\n\nconst defaultTemplate = `\nimport {defineCliConfig} from 'sanity/cli'\n\nexport default defineCliConfig({\n api: {\n projectId: '%projectId%',\n dataset: '%dataset%'\n },\n deployment: {\n /**\n * Enable auto-updates for studios.\n * Learn more at https://www.sanity.io/docs/studio/latest-version-of-sanity#k47faf43faf56\n */\n autoUpdates: __BOOL__autoUpdates__,\n },\n})\n`\n\ninterface GenerateCliConfigOptions {\n autoUpdates: boolean\n dataset: string\n isWorkbenchApp: boolean\n name: string\n projectId: string\n slug: string\n title: string\n\n organizationId?: string\n}\n\nexport function createCliConfig(options: GenerateCliConfigOptions): string {\n const {isWorkbenchApp, ...variables} = options\n return processTemplate({\n includeBooleanTransform: true,\n template: isWorkbenchApp ? workbenchStudioConfigTemplate : defaultTemplate,\n variables,\n })\n}\n"],"names":["workbenchStudioConfigTemplate","processTemplate","defaultTemplate","createCliConfig","options","isWorkbenchApp","variables","includeBooleanTransform","template"],"mappings":"AAAA,SAAQA,6BAA6B,QAAO,6BAA4B;AAExE,SAAQC,eAAe,QAAO,uBAAsB;AAEpD,MAAMC,kBAAkB,CAAC;;;;;;;;;;;;;;;;AAgBzB,CAAC;AAcD,OAAO,SAASC,gBAAgBC,OAAiC;IAC/D,MAAM,EAACC,cAAc,EAAE,GAAGC,WAAU,GAAGF;IACvC,OAAOH,gBAAgB;QACrBM,yBAAyB;QACzBC,UAAUH,iBAAiBL,gCAAgCE;QAC3DI;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/init/createCliConfig.ts"],"sourcesContent":["import {workbenchStudioConfigTemplate} from '@sanity/workbench-cli/init'\n\nimport {processTemplate} from './processTemplate.js'\n\nconst defaultTemplate = `\nimport {defineCliConfig} from 'sanity/cli'\n\nexport default defineCliConfig({\n api: {\n projectId: '%projectId%',\n dataset: '%dataset%'\n },\n deployment: {\n /**\n * Enable auto-updates for studios.\n * Learn more at https://www.sanity.io/docs/studio/latest-version-of-sanity#k47faf43faf56\n */\n autoUpdates: __BOOL__autoUpdates__,\n },\n})\n`\n\ninterface GenerateCliConfigOptions {\n autoUpdates: boolean\n dataset: string\n isWorkbenchApp: boolean\n projectId: string\n slug: string\n title: string\n\n organizationId?: string\n}\n\nexport function createCliConfig(options: GenerateCliConfigOptions): string {\n const {isWorkbenchApp, ...variables} = options\n return processTemplate({\n includeBooleanTransform: true,\n template: isWorkbenchApp ? workbenchStudioConfigTemplate : defaultTemplate,\n variables,\n })\n}\n"],"names":["workbenchStudioConfigTemplate","processTemplate","defaultTemplate","createCliConfig","options","isWorkbenchApp","variables","includeBooleanTransform","template"],"mappings":"AAAA,SAAQA,6BAA6B,QAAO,6BAA4B;AAExE,SAAQC,eAAe,QAAO,uBAAsB;AAEpD,MAAMC,kBAAkB,CAAC;;;;;;;;;;;;;;;;AAgBzB,CAAC;AAaD,OAAO,SAASC,gBAAgBC,OAAiC;IAC/D,MAAM,EAACC,cAAc,EAAE,GAAGC,WAAU,GAAGF;IACvC,OAAOH,gBAAgB;QACrBM,yBAAyB;QACzBC,UAAUH,iBAAiBL,gCAAgCE;QAC3DI;IACF;AACF"}
@@ -177,7 +177,7 @@ export async function initNextJs({ datasetName, detectedFramework, envFilename,
177
177
  'styled-components@6'
178
178
  ];
179
179
  if (templateToUse === 'blog') {
180
- packages.push('@sanity/icons');
180
+ packages.push('@sanity/icons@5');
181
181
  }
182
182
  await installNewPackages({
183
183
  packageManager: chosen,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/init/initNextJs.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport {mkdir, writeFile} from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {type Output, subdebug, type TelemetryUserProperties} from '@sanity/cli-core'\nimport {confirm} from '@sanity/cli-core/ux'\nimport {type TelemetryTrace} from '@sanity/telemetry'\nimport {execa, type Options} from 'execa'\n\nimport {\n promptForAppendEnv,\n promptForEmbeddedStudio,\n promptForNextTemplate,\n promptForStudioPath,\n} from '../../prompts/init/nextjs.js'\nimport {promptForTypeScript} from '../../prompts/init/promptForTypescript.js'\nimport {createCorsOrigin, listCorsOrigins} from '../../services/cors.js'\nimport {type InitStepResult} from '../../telemetry/init.telemetry.js'\nimport {getPeerDependencies} from '../../util/packageManager/getPeerDependencies.js'\nimport {installNewPackages} from '../../util/packageManager/installPackages.js'\nimport {\n getPartialEnvWithNpmPath,\n type PackageManager,\n} from '../../util/packageManager/packageManagerChoice.js'\nimport {type EditorName} from '../mcp/editorConfigs.js'\nimport {countNestedFolders} from './countNestedFolders.js'\nimport {createOrAppendEnvVars} from './env/createOrAppendEnvVars.js'\nimport {InitError} from './initError.js'\nimport {\n flagOrDefault,\n getPostInitMCPPrompt,\n shouldPrompt,\n writeStagingEnvIfNeeded,\n} from './initHelpers.js'\nimport {resolvePackageManager} from './resolvePackageManager.js'\nimport {\n sanityCliTemplate,\n sanityConfigTemplate,\n sanityFolder,\n sanityStudioTemplate,\n} from './templates/nextjs/index.js'\nimport {type InitOptions, type VersionedFramework} from './types.js'\n\nconst debug = subdebug('init')\n\nasync function writeOrOverwrite(\n filePath: string,\n content: string,\n workDir: string,\n options: InitOptions,\n) {\n if (existsSync(filePath)) {\n let overwrite = flagOrDefault(options.overwriteFiles, false)\n if (shouldPrompt(options.unattended, options.overwriteFiles)) {\n overwrite = await confirm({\n default: false,\n message: `File ${styleText(\n 'yellow',\n filePath.replace(workDir, ''),\n )} already exists. Do you want to overwrite it?`,\n })\n }\n\n if (!overwrite) {\n return\n }\n }\n\n // make folder if not exists\n const folderPath = path.dirname(filePath)\n\n try {\n await mkdir(folderPath, {recursive: true})\n } catch {\n debug('Error creating folder %s', folderPath)\n }\n\n await writeFile(filePath, content, {\n encoding: 'utf8',\n })\n}\n\n// write sanity folder files\nasync function writeSourceFiles({\n fileExtension,\n files,\n folderPath,\n options,\n srcFolderPrefix,\n workDir,\n}: {\n fileExtension: string\n files: Record<string, Record<string, string> | string>\n folderPath?: string\n options: InitOptions\n srcFolderPrefix?: boolean\n workDir: string\n}) {\n for (const [filePath, content] of Object.entries(files)) {\n // check if file ends with full stop to indicate it's file and not directory (this only works with our template tree structure)\n if (filePath.includes('.') && typeof content === 'string') {\n await writeOrOverwrite(\n path.join(\n workDir,\n srcFolderPrefix ? 'src' : '',\n 'sanity',\n folderPath || '',\n `${filePath}${fileExtension}`,\n ),\n content,\n workDir,\n options,\n )\n } else {\n await mkdir(path.join(workDir, srcFolderPrefix ? 'src' : '', 'sanity', filePath), {\n recursive: true,\n })\n if (typeof content === 'object') {\n await writeSourceFiles({\n fileExtension,\n files: content,\n folderPath: filePath,\n options,\n srcFolderPrefix,\n workDir,\n })\n }\n }\n }\n}\n\nexport async function initNextJs({\n datasetName,\n detectedFramework,\n envFilename,\n mcpConfigured,\n options,\n output,\n projectId,\n trace,\n workDir,\n}: {\n datasetName: string\n detectedFramework: VersionedFramework | null\n envFilename: string\n mcpConfigured: EditorName[]\n options: InitOptions\n output: Output\n projectId: string\n trace: TelemetryTrace<TelemetryUserProperties, InitStepResult>\n workDir: string\n}): Promise<void> {\n const {nextjsAppendEnv, nextjsEmbedStudio, packageManager, template, typescript, unattended} =\n options\n let useTypeScript = flagOrDefault(typescript, true)\n if (shouldPrompt(unattended, typescript)) {\n useTypeScript = await promptForTypeScript()\n }\n trace.log({\n selectedOption: useTypeScript ? 'yes' : 'no',\n step: 'useTypeScript',\n })\n\n const fileExtension = useTypeScript ? 'ts' : 'js'\n let embeddedStudio = flagOrDefault(nextjsEmbedStudio, true)\n if (shouldPrompt(unattended, nextjsEmbedStudio)) {\n embeddedStudio = await promptForEmbeddedStudio()\n }\n let hasSrcFolder = false\n\n if (embeddedStudio) {\n // find source path (app or src/app)\n const appDir = 'app'\n let srcPath = path.join(workDir, appDir)\n\n if (!existsSync(srcPath)) {\n srcPath = path.join(workDir, 'src', appDir)\n hasSrcFolder = true\n if (!existsSync(srcPath)) {\n try {\n await mkdir(srcPath, {recursive: true})\n } catch {\n debug('Error creating folder %s', srcPath)\n }\n }\n }\n\n const studioPath = unattended ? '/studio' : await promptForStudioPath()\n\n const embeddedStudioRouteFilePath = path.join(\n srcPath,\n `${studioPath}/`,\n `[[...tool]]/page.${fileExtension}x`,\n )\n\n // this selects the correct template string based on whether the user is using the app or pages directory and\n // replaces the \":configPath:\" placeholder in the template with the correct path to the sanity.config.ts file.\n // we account for the user-defined embeddedStudioPath (default /studio) is accounted for by creating enough \"../\"\n // relative paths to reach the root level of the project\n await writeOrOverwrite(\n embeddedStudioRouteFilePath,\n sanityStudioTemplate.replace(\n ':configPath:',\n `${'../'.repeat(countNestedFolders(path.dirname(embeddedStudioRouteFilePath.slice(workDir.length))))}sanity.config`,\n ),\n workDir,\n options,\n )\n\n const sanityConfigPath = path.join(workDir, `sanity.config.${fileExtension}`)\n await writeOrOverwrite(\n sanityConfigPath,\n sanityConfigTemplate(hasSrcFolder)\n .replace(':route:', embeddedStudioRouteFilePath.slice(workDir.length).replace('src/', ''))\n .replace(':basePath:', studioPath),\n workDir,\n options,\n )\n }\n\n const sanityCliPath = path.join(workDir, `sanity.cli.${fileExtension}`)\n await writeOrOverwrite(sanityCliPath, sanityCliTemplate, workDir, options)\n\n let templateToUse = template ?? 'clean'\n if (shouldPrompt(unattended, template)) {\n templateToUse = await promptForNextTemplate()\n }\n\n await writeSourceFiles({\n fileExtension,\n files: sanityFolder(useTypeScript, templateToUse as 'blog' | 'clean'),\n folderPath: undefined,\n options,\n srcFolderPrefix: hasSrcFolder,\n workDir,\n })\n\n let appendEnv = flagOrDefault(nextjsAppendEnv, true)\n if (shouldPrompt(unattended, nextjsAppendEnv)) {\n appendEnv = await promptForAppendEnv(envFilename)\n }\n\n if (appendEnv) {\n await createOrAppendEnvVars({\n envVars: {\n DATASET: datasetName,\n PROJECT_ID: projectId,\n },\n filename: envFilename,\n framework: detectedFramework,\n log: true,\n output,\n outputPath: workDir,\n })\n }\n\n if (embeddedStudio) {\n const nextjsLocalDevOrigin = 'http://localhost:3000'\n const existingCorsOrigins = await listCorsOrigins(projectId)\n const hasExistingCorsOrigin = existingCorsOrigins.some(\n (item: {origin: string}) => item.origin === nextjsLocalDevOrigin,\n )\n if (!hasExistingCorsOrigin) {\n try {\n const createCorsRes = await createCorsOrigin({\n allowCredentials: true,\n origin: nextjsLocalDevOrigin,\n projectId,\n })\n\n output.log(\n createCorsRes.id\n ? `Added ${nextjsLocalDevOrigin} to CORS origins`\n : `Failed to add ${nextjsLocalDevOrigin} to CORS origins`,\n )\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n debug(`Error creating new CORS Origin ${nextjsLocalDevOrigin}: ${message}`)\n throw new InitError(`Failed to add ${nextjsLocalDevOrigin} to CORS origins: ${message}`, 1)\n }\n }\n }\n\n const chosen = await resolvePackageManager({\n interactive: !unattended,\n output,\n packageManager: packageManager as PackageManager,\n targetDir: workDir,\n })\n trace.log({selectedOption: chosen, step: 'selectPackageManager'})\n const packages = ['@sanity/vision@5', 'sanity@5', '@sanity/image-url@2', 'styled-components@6']\n if (templateToUse === 'blog') {\n packages.push('@sanity/icons')\n }\n await installNewPackages(\n {\n packageManager: chosen,\n packages,\n },\n {\n output,\n workDir,\n },\n )\n\n // will refactor this later\n const execOptions: Options = {\n cwd: workDir,\n encoding: 'utf8',\n env: getPartialEnvWithNpmPath(workDir),\n stdio: 'inherit',\n }\n\n switch (chosen) {\n case 'npm': {\n await execa('npm', ['install', 'next-sanity@13'], execOptions)\n break\n }\n case 'pnpm': {\n await execa('pnpm', ['install', 'next-sanity@13'], execOptions)\n break\n }\n case 'yarn': {\n const peerDeps = await getPeerDependencies('next-sanity@13', workDir)\n await installNewPackages(\n {packageManager: 'yarn', packages: ['next-sanity@13', ...peerDeps]},\n {output, workDir},\n )\n break\n }\n default: {\n // bun and manual - do nothing or handle differently\n break\n }\n }\n\n output.log(\n `\\n${styleText('green', 'Success!')} Your Sanity configuration files has been added to this project`,\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\n await writeStagingEnvIfNeeded(output, workDir)\n}\n"],"names":["existsSync","mkdir","writeFile","path","styleText","subdebug","confirm","execa","promptForAppendEnv","promptForEmbeddedStudio","promptForNextTemplate","promptForStudioPath","promptForTypeScript","createCorsOrigin","listCorsOrigins","getPeerDependencies","installNewPackages","getPartialEnvWithNpmPath","countNestedFolders","createOrAppendEnvVars","InitError","flagOrDefault","getPostInitMCPPrompt","shouldPrompt","writeStagingEnvIfNeeded","resolvePackageManager","sanityCliTemplate","sanityConfigTemplate","sanityFolder","sanityStudioTemplate","debug","writeOrOverwrite","filePath","content","workDir","options","overwrite","overwriteFiles","unattended","default","message","replace","folderPath","dirname","recursive","encoding","writeSourceFiles","fileExtension","files","srcFolderPrefix","Object","entries","includes","join","initNextJs","datasetName","detectedFramework","envFilename","mcpConfigured","output","projectId","trace","nextjsAppendEnv","nextjsEmbedStudio","packageManager","template","typescript","useTypeScript","log","selectedOption","step","embeddedStudio","hasSrcFolder","appDir","srcPath","studioPath","embeddedStudioRouteFilePath","repeat","slice","length","sanityConfigPath","sanityCliPath","templateToUse","undefined","appendEnv","envVars","DATASET","PROJECT_ID","filename","framework","outputPath","nextjsLocalDevOrigin","existingCorsOrigins","hasExistingCorsOrigin","some","item","origin","createCorsRes","allowCredentials","id","error","Error","String","chosen","interactive","targetDir","packages","push","execOptions","cwd","env","stdio","peerDeps"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,SAAQC,KAAK,EAAEC,SAAS,QAAO,mBAAkB;AACjD,OAAOC,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAqBC,QAAQ,QAAqC,mBAAkB;AACpF,SAAQC,OAAO,QAAO,sBAAqB;AAE3C,SAAQC,KAAK,QAAqB,QAAO;AAEzC,SACEC,kBAAkB,EAClBC,uBAAuB,EACvBC,qBAAqB,EACrBC,mBAAmB,QACd,+BAA8B;AACrC,SAAQC,mBAAmB,QAAO,4CAA2C;AAC7E,SAAQC,gBAAgB,EAAEC,eAAe,QAAO,yBAAwB;AAExE,SAAQC,mBAAmB,QAAO,mDAAkD;AACpF,SAAQC,kBAAkB,QAAO,+CAA8C;AAC/E,SACEC,wBAAwB,QAEnB,oDAAmD;AAE1D,SAAQC,kBAAkB,QAAO,0BAAyB;AAC1D,SAAQC,qBAAqB,QAAO,iCAAgC;AACpE,SAAQC,SAAS,QAAO,iBAAgB;AACxC,SACEC,aAAa,EACbC,oBAAoB,EACpBC,YAAY,EACZC,uBAAuB,QAClB,mBAAkB;AACzB,SAAQC,qBAAqB,QAAO,6BAA4B;AAChE,SACEC,iBAAiB,EACjBC,oBAAoB,EACpBC,YAAY,EACZC,oBAAoB,QACf,8BAA6B;AAGpC,MAAMC,QAAQzB,SAAS;AAEvB,eAAe0B,iBACbC,QAAgB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jG,oBAAoB,kBAAkBmB;gBAC7D,MAAMlB,mBACJ;oBAACgD,gBAAgB;oBAAQ0C,UAAU;wBAAC;2BAAqBM;qBAAS;gBAAA,GAClE;oBAACrD;oBAAQzB;gBAAO;gBAElB;YACF;QACA;YAAS;gBAEP;YACF;IACF;IAEAyB,OAAOS,GAAG,CACR,CAAC,EAAE,EAAEhE,UAAU,SAAS,YAAY,+DAA+D,CAAC;IAEtG,IAAIsD,iBAAiBA,cAAcqB,MAAM,GAAG,GAAG;QAC7C,MAAMvC,UAAU,MAAMlB,qBAAqBoC;QAC3CC,OAAOS,GAAG,CAAC,CAAC,EAAE,EAAE5B,SAAS;QACzBmB,OAAOS,GAAG,CAAC,CAAC,cAAc,EAAEhE,UAAU,QAAQ,0BAA0B;QACxEuD,OAAOS,GAAG,CACR,CAAC,2CAA2C,EAAEhE,UAAU,QAAQ,yCAAyC;IAE7G;IAEA,MAAMoB,wBAAwBmC,QAAQzB;AACxC"}
1
+ {"version":3,"sources":["../../../src/actions/init/initNextJs.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport {mkdir, writeFile} from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {type Output, subdebug, type TelemetryUserProperties} from '@sanity/cli-core'\nimport {confirm} from '@sanity/cli-core/ux'\nimport {type TelemetryTrace} from '@sanity/telemetry'\nimport {execa, type Options} from 'execa'\n\nimport {\n promptForAppendEnv,\n promptForEmbeddedStudio,\n promptForNextTemplate,\n promptForStudioPath,\n} from '../../prompts/init/nextjs.js'\nimport {promptForTypeScript} from '../../prompts/init/promptForTypescript.js'\nimport {createCorsOrigin, listCorsOrigins} from '../../services/cors.js'\nimport {type InitStepResult} from '../../telemetry/init.telemetry.js'\nimport {getPeerDependencies} from '../../util/packageManager/getPeerDependencies.js'\nimport {installNewPackages} from '../../util/packageManager/installPackages.js'\nimport {\n getPartialEnvWithNpmPath,\n type PackageManager,\n} from '../../util/packageManager/packageManagerChoice.js'\nimport {type EditorName} from '../mcp/editorConfigs.js'\nimport {countNestedFolders} from './countNestedFolders.js'\nimport {createOrAppendEnvVars} from './env/createOrAppendEnvVars.js'\nimport {InitError} from './initError.js'\nimport {\n flagOrDefault,\n getPostInitMCPPrompt,\n shouldPrompt,\n writeStagingEnvIfNeeded,\n} from './initHelpers.js'\nimport {resolvePackageManager} from './resolvePackageManager.js'\nimport {\n sanityCliTemplate,\n sanityConfigTemplate,\n sanityFolder,\n sanityStudioTemplate,\n} from './templates/nextjs/index.js'\nimport {type InitOptions, type VersionedFramework} from './types.js'\n\nconst debug = subdebug('init')\n\nasync function writeOrOverwrite(\n filePath: string,\n content: string,\n workDir: string,\n options: InitOptions,\n) {\n if (existsSync(filePath)) {\n let overwrite = flagOrDefault(options.overwriteFiles, false)\n if (shouldPrompt(options.unattended, options.overwriteFiles)) {\n overwrite = await confirm({\n default: false,\n message: `File ${styleText(\n 'yellow',\n filePath.replace(workDir, ''),\n )} already exists. Do you want to overwrite it?`,\n })\n }\n\n if (!overwrite) {\n return\n }\n }\n\n // make folder if not exists\n const folderPath = path.dirname(filePath)\n\n try {\n await mkdir(folderPath, {recursive: true})\n } catch {\n debug('Error creating folder %s', folderPath)\n }\n\n await writeFile(filePath, content, {\n encoding: 'utf8',\n })\n}\n\n// write sanity folder files\nasync function writeSourceFiles({\n fileExtension,\n files,\n folderPath,\n options,\n srcFolderPrefix,\n workDir,\n}: {\n fileExtension: string\n files: Record<string, Record<string, string> | string>\n folderPath?: string\n options: InitOptions\n srcFolderPrefix?: boolean\n workDir: string\n}) {\n for (const [filePath, content] of Object.entries(files)) {\n // check if file ends with full stop to indicate it's file and not directory (this only works with our template tree structure)\n if (filePath.includes('.') && typeof content === 'string') {\n await writeOrOverwrite(\n path.join(\n workDir,\n srcFolderPrefix ? 'src' : '',\n 'sanity',\n folderPath || '',\n `${filePath}${fileExtension}`,\n ),\n content,\n workDir,\n options,\n )\n } else {\n await mkdir(path.join(workDir, srcFolderPrefix ? 'src' : '', 'sanity', filePath), {\n recursive: true,\n })\n if (typeof content === 'object') {\n await writeSourceFiles({\n fileExtension,\n files: content,\n folderPath: filePath,\n options,\n srcFolderPrefix,\n workDir,\n })\n }\n }\n }\n}\n\nexport async function initNextJs({\n datasetName,\n detectedFramework,\n envFilename,\n mcpConfigured,\n options,\n output,\n projectId,\n trace,\n workDir,\n}: {\n datasetName: string\n detectedFramework: VersionedFramework | null\n envFilename: string\n mcpConfigured: EditorName[]\n options: InitOptions\n output: Output\n projectId: string\n trace: TelemetryTrace<TelemetryUserProperties, InitStepResult>\n workDir: string\n}): Promise<void> {\n const {nextjsAppendEnv, nextjsEmbedStudio, packageManager, template, typescript, unattended} =\n options\n let useTypeScript = flagOrDefault(typescript, true)\n if (shouldPrompt(unattended, typescript)) {\n useTypeScript = await promptForTypeScript()\n }\n trace.log({\n selectedOption: useTypeScript ? 'yes' : 'no',\n step: 'useTypeScript',\n })\n\n const fileExtension = useTypeScript ? 'ts' : 'js'\n let embeddedStudio = flagOrDefault(nextjsEmbedStudio, true)\n if (shouldPrompt(unattended, nextjsEmbedStudio)) {\n embeddedStudio = await promptForEmbeddedStudio()\n }\n let hasSrcFolder = false\n\n if (embeddedStudio) {\n // find source path (app or src/app)\n const appDir = 'app'\n let srcPath = path.join(workDir, appDir)\n\n if (!existsSync(srcPath)) {\n srcPath = path.join(workDir, 'src', appDir)\n hasSrcFolder = true\n if (!existsSync(srcPath)) {\n try {\n await mkdir(srcPath, {recursive: true})\n } catch {\n debug('Error creating folder %s', srcPath)\n }\n }\n }\n\n const studioPath = unattended ? '/studio' : await promptForStudioPath()\n\n const embeddedStudioRouteFilePath = path.join(\n srcPath,\n `${studioPath}/`,\n `[[...tool]]/page.${fileExtension}x`,\n )\n\n // this selects the correct template string based on whether the user is using the app or pages directory and\n // replaces the \":configPath:\" placeholder in the template with the correct path to the sanity.config.ts file.\n // we account for the user-defined embeddedStudioPath (default /studio) is accounted for by creating enough \"../\"\n // relative paths to reach the root level of the project\n await writeOrOverwrite(\n embeddedStudioRouteFilePath,\n sanityStudioTemplate.replace(\n ':configPath:',\n `${'../'.repeat(countNestedFolders(path.dirname(embeddedStudioRouteFilePath.slice(workDir.length))))}sanity.config`,\n ),\n workDir,\n options,\n )\n\n const sanityConfigPath = path.join(workDir, `sanity.config.${fileExtension}`)\n await writeOrOverwrite(\n sanityConfigPath,\n sanityConfigTemplate(hasSrcFolder)\n .replace(':route:', embeddedStudioRouteFilePath.slice(workDir.length).replace('src/', ''))\n .replace(':basePath:', studioPath),\n workDir,\n options,\n )\n }\n\n const sanityCliPath = path.join(workDir, `sanity.cli.${fileExtension}`)\n await writeOrOverwrite(sanityCliPath, sanityCliTemplate, workDir, options)\n\n let templateToUse = template ?? 'clean'\n if (shouldPrompt(unattended, template)) {\n templateToUse = await promptForNextTemplate()\n }\n\n await writeSourceFiles({\n fileExtension,\n files: sanityFolder(useTypeScript, templateToUse as 'blog' | 'clean'),\n folderPath: undefined,\n options,\n srcFolderPrefix: hasSrcFolder,\n workDir,\n })\n\n let appendEnv = flagOrDefault(nextjsAppendEnv, true)\n if (shouldPrompt(unattended, nextjsAppendEnv)) {\n appendEnv = await promptForAppendEnv(envFilename)\n }\n\n if (appendEnv) {\n await createOrAppendEnvVars({\n envVars: {\n DATASET: datasetName,\n PROJECT_ID: projectId,\n },\n filename: envFilename,\n framework: detectedFramework,\n log: true,\n output,\n outputPath: workDir,\n })\n }\n\n if (embeddedStudio) {\n const nextjsLocalDevOrigin = 'http://localhost:3000'\n const existingCorsOrigins = await listCorsOrigins(projectId)\n const hasExistingCorsOrigin = existingCorsOrigins.some(\n (item: {origin: string}) => item.origin === nextjsLocalDevOrigin,\n )\n if (!hasExistingCorsOrigin) {\n try {\n const createCorsRes = await createCorsOrigin({\n allowCredentials: true,\n origin: nextjsLocalDevOrigin,\n projectId,\n })\n\n output.log(\n createCorsRes.id\n ? `Added ${nextjsLocalDevOrigin} to CORS origins`\n : `Failed to add ${nextjsLocalDevOrigin} to CORS origins`,\n )\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n debug(`Error creating new CORS Origin ${nextjsLocalDevOrigin}: ${message}`)\n throw new InitError(`Failed to add ${nextjsLocalDevOrigin} to CORS origins: ${message}`, 1)\n }\n }\n }\n\n const chosen = await resolvePackageManager({\n interactive: !unattended,\n output,\n packageManager: packageManager as PackageManager,\n targetDir: workDir,\n })\n trace.log({selectedOption: chosen, step: 'selectPackageManager'})\n const packages = ['@sanity/vision@5', 'sanity@5', '@sanity/image-url@2', 'styled-components@6']\n if (templateToUse === 'blog') {\n packages.push('@sanity/icons@5')\n }\n await installNewPackages(\n {\n packageManager: chosen,\n packages,\n },\n {\n output,\n workDir,\n },\n )\n\n // will refactor this later\n const execOptions: Options = {\n cwd: workDir,\n encoding: 'utf8',\n env: getPartialEnvWithNpmPath(workDir),\n stdio: 'inherit',\n }\n\n switch (chosen) {\n case 'npm': {\n await execa('npm', ['install', 'next-sanity@13'], execOptions)\n break\n }\n case 'pnpm': {\n await execa('pnpm', ['install', 'next-sanity@13'], execOptions)\n break\n }\n case 'yarn': {\n const peerDeps = await getPeerDependencies('next-sanity@13', workDir)\n await installNewPackages(\n {packageManager: 'yarn', packages: ['next-sanity@13', ...peerDeps]},\n {output, workDir},\n )\n break\n }\n default: {\n // bun and manual - do nothing or handle differently\n break\n }\n }\n\n output.log(\n `\\n${styleText('green', 'Success!')} Your Sanity configuration files has been added to this project`,\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\n await writeStagingEnvIfNeeded(output, workDir)\n}\n"],"names":["existsSync","mkdir","writeFile","path","styleText","subdebug","confirm","execa","promptForAppendEnv","promptForEmbeddedStudio","promptForNextTemplate","promptForStudioPath","promptForTypeScript","createCorsOrigin","listCorsOrigins","getPeerDependencies","installNewPackages","getPartialEnvWithNpmPath","countNestedFolders","createOrAppendEnvVars","InitError","flagOrDefault","getPostInitMCPPrompt","shouldPrompt","writeStagingEnvIfNeeded","resolvePackageManager","sanityCliTemplate","sanityConfigTemplate","sanityFolder","sanityStudioTemplate","debug","writeOrOverwrite","filePath","content","workDir","options","overwrite","overwriteFiles","unattended","default","message","replace","folderPath","dirname","recursive","encoding","writeSourceFiles","fileExtension","files","srcFolderPrefix","Object","entries","includes","join","initNextJs","datasetName","detectedFramework","envFilename","mcpConfigured","output","projectId","trace","nextjsAppendEnv","nextjsEmbedStudio","packageManager","template","typescript","useTypeScript","log","selectedOption","step","embeddedStudio","hasSrcFolder","appDir","srcPath","studioPath","embeddedStudioRouteFilePath","repeat","slice","length","sanityConfigPath","sanityCliPath","templateToUse","undefined","appendEnv","envVars","DATASET","PROJECT_ID","filename","framework","outputPath","nextjsLocalDevOrigin","existingCorsOrigins","hasExistingCorsOrigin","some","item","origin","createCorsRes","allowCredentials","id","error","Error","String","chosen","interactive","targetDir","packages","push","execOptions","cwd","env","stdio","peerDeps"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,SAAQC,KAAK,EAAEC,SAAS,QAAO,mBAAkB;AACjD,OAAOC,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAqBC,QAAQ,QAAqC,mBAAkB;AACpF,SAAQC,OAAO,QAAO,sBAAqB;AAE3C,SAAQC,KAAK,QAAqB,QAAO;AAEzC,SACEC,kBAAkB,EAClBC,uBAAuB,EACvBC,qBAAqB,EACrBC,mBAAmB,QACd,+BAA8B;AACrC,SAAQC,mBAAmB,QAAO,4CAA2C;AAC7E,SAAQC,gBAAgB,EAAEC,eAAe,QAAO,yBAAwB;AAExE,SAAQC,mBAAmB,QAAO,mDAAkD;AACpF,SAAQC,kBAAkB,QAAO,+CAA8C;AAC/E,SACEC,wBAAwB,QAEnB,oDAAmD;AAE1D,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ACF;IAGF,2BAA2B;IAC3B,MAAM0E,cAAuB;QAC3BC,KAAK3E;QACLW,UAAU;QACViE,KAAK7F,yBAAyBiB;QAC9B6E,OAAO;IACT;IAEA,OAAQR;QACN,KAAK;YAAO;gBACV,MAAMhG,MAAM,OAAO;oBAAC;oBAAW;iBAAiB,EAAEqG;gBAClD;YACF;QACA,KAAK;YAAQ;gBACX,MAAMrG,MAAM,QAAQ;oBAAC;oBAAW;iBAAiB,EAAEqG;gBACnD;YACF;QACA,KAAK;YAAQ;gBACX,MAAMI,WAAW,MAAMjG,oBAAoB,kBAAkBmB;gBAC7D,MAAMlB,mBACJ;oBAACgD,gBAAgB;oBAAQ0C,UAAU;wBAAC;2BAAqBM;qBAAS;gBAAA,GAClE;oBAACrD;oBAAQzB;gBAAO;gBAElB;YACF;QACA;YAAS;gBAEP;YACF;IACF;IAEAyB,OAAOS,GAAG,CACR,CAAC,EAAE,EAAEhE,UAAU,SAAS,YAAY,+DAA+D,CAAC;IAEtG,IAAIsD,iBAAiBA,cAAcqB,MAAM,GAAG,GAAG;QAC7C,MAAMvC,UAAU,MAAMlB,qBAAqBoC;QAC3CC,OAAOS,GAAG,CAAC,CAAC,EAAE,EAAE5B,SAAS;QACzBmB,OAAOS,GAAG,CAAC,CAAC,cAAc,EAAEhE,UAAU,QAAQ,0BAA0B;QACxEuD,OAAOS,GAAG,CACR,CAAC,2CAA2C,EAAEhE,UAAU,QAAQ,yCAAyC;IAE7G;IAEA,MAAMoB,wBAAwBmC,QAAQzB;AACxC"}
@@ -12,7 +12,7 @@ async function promptForDatasetImport(message) {
12
12
  message: message || 'This template includes a sample dataset, would you like to use it?'
13
13
  });
14
14
  }
15
- export async function initStudio({ datasetName, defaults, displayName, isFirstProject, mcpConfigured, options, organizationId, output, outputPath, projectId, remoteTemplateInfo, sluggedName, trace, workbench, workDir }) {
15
+ export async function initStudio({ datasetName, defaults, displayName, isFirstProject, mcpConfigured, options, organizationId, output, outputPath, preclaim = false, projectId, remoteTemplateInfo, sluggedName, trace, workbench, workDir }) {
16
16
  const { importDataset, unattended } = options;
17
17
  const { template: resolvedTemplate, templateName, useTypeScript } = await selectTemplate({
18
18
  options,
@@ -28,11 +28,13 @@ export async function initStudio({ datasetName, defaults, displayName, isFirstPr
28
28
  selectedOption: shouldImport ? 'yes' : 'no',
29
29
  step: 'importTemplateDataset'
30
30
  });
31
- try {
32
- await updateProjectInitializedAt(projectId);
33
- } catch (err) {
34
- // Non-critical update
35
- debug('Failed to update cliInitializedAt metadata', err);
31
+ if (!preclaim) {
32
+ try {
33
+ await updateProjectInitializedAt(projectId);
34
+ } catch (err) {
35
+ // Non-critical update
36
+ debug('Failed to update cliInitializedAt metadata', err);
37
+ }
36
38
  }
37
39
  const { pkgManager } = await scaffoldAndInstall({
38
40
  datasetName,
@@ -77,6 +79,8 @@ export async function initStudio({ datasetName, defaults, displayName, isFirstPr
77
79
  output.log('and create a new clean dataset with');
78
80
  output.log(` ${styleText('cyan', `npx sanity dataset create <name>`)}\n`);
79
81
  }
82
+ // `sanity new` owns the combined Studio/frontend outro.
83
+ if (preclaim) return;
80
84
  const devCommandMap = {
81
85
  bun: 'bun dev',
82
86
  manual: 'npm run dev',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/init/initStudio.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {getCliToken, type Output, subdebug, type TelemetryUserProperties} from '@sanity/cli-core'\nimport {confirm} from '@sanity/cli-core/ux'\nimport {type TelemetryTrace} from '@sanity/telemetry'\n\nimport {updateProjectInitializedAt} from '../../services/projects.js'\nimport {type InitStepResult} from '../../telemetry/init.telemetry.js'\nimport {type PackageManager} from '../../util/packageManager/packageManagerChoice.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\nconst debug = subdebug('init')\n\nasync function promptForDatasetImport(message?: string): Promise<boolean> {\n return confirm({\n default: true,\n message: message || 'This template includes a sample dataset, would you like to use it?',\n })\n}\n\nexport async function initStudio({\n datasetName,\n defaults,\n displayName,\n isFirstProject,\n mcpConfigured,\n options,\n organizationId,\n output,\n outputPath,\n projectId,\n remoteTemplateInfo,\n sluggedName,\n trace,\n workbench,\n workDir,\n}: {\n datasetName: string\n defaults: {projectName: string}\n displayName: string\n isFirstProject: boolean\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 workbench: boolean\n workDir: string\n}): Promise<void> {\n const {importDataset, unattended} = options\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 // If the template has a sample dataset, prompt the user whether or not we should import it\n const shouldImport =\n resolvedTemplate?.datasetUrl &&\n (importDataset ??\n (!unattended && (await promptForDatasetImport(resolvedTemplate.importPrompt))))\n\n trace.log({\n selectedOption: shouldImport ? 'yes' : 'no',\n step: 'importTemplateDataset',\n })\n\n try {\n await updateProjectInitializedAt(projectId)\n } catch (err) {\n // Non-critical update\n debug('Failed to update cliInitializedAt metadata', err)\n }\n\n const {pkgManager} = 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 workbench,\n workDir,\n })\n\n // Prompt for dataset import (if a dataset is defined)\n if (shouldImport && resolvedTemplate?.datasetUrl) {\n const token = await getCliToken()\n if (!token) {\n throw new InitError('Authentication required to import dataset', 1)\n }\n // eslint-disable-next-line no-restricted-syntax\n const {ImportDatasetCommand} = await import('../../commands/datasets/import.js')\n await ImportDatasetCommand.run(\n [\n resolvedTemplate.datasetUrl,\n '--project-id',\n projectId,\n '--dataset',\n datasetName,\n '--token',\n token,\n '--missing',\n ],\n {\n root: outputPath,\n },\n )\n\n output.log('')\n output.log('If you want to delete the imported data, use')\n output.log(` ${styleText('cyan', `npx sanity dataset delete ${datasetName}`)}`)\n output.log('and create a new clean dataset with')\n output.log(` ${styleText('cyan', `npx sanity dataset create <name>`)}\\n`)\n }\n\n const devCommandMap: Record<PackageManager, string> = {\n bun: 'bun dev',\n manual: 'npm run dev',\n npm: 'npm run dev',\n pnpm: 'pnpm dev',\n yarn: 'yarn dev',\n }\n const devCommand = devCommandMap[pkgManager]\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 Studios here\n output.log(`\\u2705 ${styleText(['green', 'bold'], 'Success!')} Your Studio has been created.`)\n if (!isCurrentDir) output.log(goToProjectDir)\n output.log(\n `\\nGet started by running ${styleText('cyan', devCommand)} to launch your Studio's development server`,\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 manage to open the project settings in a browser`)\n output.log(`npx sanity help to explore the CLI manual`)\n\n if (isFirstProject) {\n trace.log({selectedOption: 'yes', step: 'sendCommunityInvite'})\n\n const DISCORD_INVITE_LINK = 'https://www.sanity.io/community/join'\n\n output.log(`\\nJoin the Sanity community: ${styleText('cyan', DISCORD_INVITE_LINK)}`)\n output.log('We look forward to seeing you there!\\n')\n }\n}\n"],"names":["styleText","getCliToken","subdebug","confirm","updateProjectInitializedAt","InitError","getPostInitMCPPrompt","scaffoldAndInstall","selectTemplate","debug","promptForDatasetImport","message","default","initStudio","datasetName","defaults","displayName","isFirstProject","mcpConfigured","options","organizationId","output","outputPath","projectId","remoteTemplateInfo","sluggedName","trace","workbench","workDir","importDataset","unattended","template","resolvedTemplate","templateName","useTypeScript","shouldImport","datasetUrl","importPrompt","log","selectedOption","step","err","pkgManager","token","ImportDatasetCommand","run","root","devCommandMap","bun","manual","npm","pnpm","yarn","devCommand","isCurrentDir","goToProjectDir","length","DISCORD_INVITE_LINK"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,WAAW,EAAeC,QAAQ,QAAqC,mBAAkB;AACjG,SAAQC,OAAO,QAAO,sBAAqB;AAG3C,SAAQC,0BAA0B,QAAO,6BAA4B;AAIrE,SAAQC,SAAS,QAAO,iBAAgB;AACxC,SAAQC,oBAAoB,QAAO,mBAAkB;AAErD,SAAQC,kBAAkB,EAAEC,cAAc,QAAO,wBAAuB;AAGxE,MAAMC,QAAQP,SAAS;AAEvB,eAAeQ,uBAAuBC,OAAgB;IACpD,OAAOR,QAAQ;QACbS,SAAS;QACTD,SAASA,WAAW;IACtB;AACF;AAEA,OAAO,eAAeE,WAAW,EAC/BC,WAAW,EACXC,QAAQ,EACRC,WAAW,EACXC,cAAc,EACdC,aAAa,EACbC,OAAO,EACPC,cAAc,EACdC,MAAM,EACNC,UAAU,EACVC,SAAS,EACTC,kBAAkB,EAClBC,WAAW,EACXC,KAAK,EACLC,SAAS,EACTC,OAAO,EAiBR;IACC,MAAM,EAACC,aAAa,EAAEC,UAAU,EAAC,GAAGX;IACpC,MAAM,EACJY,UAAUC,gBAAgB,EAC1BC,YAAY,EACZC,aAAa,EACd,GAAG,MAAM1B,eAAe;QACvBW;QACAK;QACAE;IACF;IAEA,IAAI,CAACF,sBAAsB,CAACQ,kBAAkB;QAC5C,MAAM,IAAI3B,UAAU,CAAC,UA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n\nimport {getCliToken, type Output, subdebug, type TelemetryUserProperties} from '@sanity/cli-core'\nimport {confirm} from '@sanity/cli-core/ux'\nimport {type TelemetryTrace} from '@sanity/telemetry'\n\nimport {updateProjectInitializedAt} from '../../services/projects.js'\nimport {type InitStepResult} from '../../telemetry/init.telemetry.js'\nimport {type PackageManager} from '../../util/packageManager/packageManagerChoice.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\nconst debug = subdebug('init')\n\nasync function promptForDatasetImport(message?: string): Promise<boolean> {\n return confirm({\n default: true,\n message: message || 'This template includes a sample dataset, would you like to use it?',\n })\n}\n\nexport async function initStudio({\n datasetName,\n defaults,\n displayName,\n isFirstProject,\n mcpConfigured,\n options,\n organizationId,\n output,\n outputPath,\n preclaim = false,\n projectId,\n remoteTemplateInfo,\n sluggedName,\n trace,\n workbench,\n workDir,\n}: {\n datasetName: string\n defaults: {projectName: string}\n displayName: string\n isFirstProject: boolean\n mcpConfigured: EditorName[]\n options: InitOptions\n organizationId: string | undefined\n output: Output\n outputPath: string\n preclaim?: boolean\n projectId: string\n remoteTemplateInfo: RepoInfo | undefined\n sluggedName: string\n trace: TelemetryTrace<TelemetryUserProperties, InitStepResult>\n workbench: boolean\n workDir: string\n}): Promise<void> {\n const {importDataset, unattended} = options\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 // If the template has a sample dataset, prompt the user whether or not we should import it\n const shouldImport =\n resolvedTemplate?.datasetUrl &&\n (importDataset ??\n (!unattended && (await promptForDatasetImport(resolvedTemplate.importPrompt))))\n\n trace.log({\n selectedOption: shouldImport ? 'yes' : 'no',\n step: 'importTemplateDataset',\n })\n\n if (!preclaim) {\n try {\n await updateProjectInitializedAt(projectId)\n } catch (err) {\n // Non-critical update\n debug('Failed to update cliInitializedAt metadata', err)\n }\n }\n\n const {pkgManager} = 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 workbench,\n workDir,\n })\n\n // Prompt for dataset import (if a dataset is defined)\n if (shouldImport && resolvedTemplate?.datasetUrl) {\n const token = await getCliToken()\n if (!token) {\n throw new InitError('Authentication required to import dataset', 1)\n }\n // eslint-disable-next-line no-restricted-syntax\n const {ImportDatasetCommand} = await import('../../commands/datasets/import.js')\n await ImportDatasetCommand.run(\n [\n resolvedTemplate.datasetUrl,\n '--project-id',\n projectId,\n '--dataset',\n datasetName,\n '--token',\n token,\n '--missing',\n ],\n {\n root: outputPath,\n },\n )\n\n output.log('')\n output.log('If you want to delete the imported data, use')\n output.log(` ${styleText('cyan', `npx sanity dataset delete ${datasetName}`)}`)\n output.log('and create a new clean dataset with')\n output.log(` ${styleText('cyan', `npx sanity dataset create <name>`)}\\n`)\n }\n\n // `sanity new` owns the combined Studio/frontend outro.\n if (preclaim) return\n\n const devCommandMap: Record<PackageManager, string> = {\n bun: 'bun dev',\n manual: 'npm run dev',\n npm: 'npm run dev',\n pnpm: 'pnpm dev',\n yarn: 'yarn dev',\n }\n const devCommand = devCommandMap[pkgManager]\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 Studios here\n output.log(`\\u2705 ${styleText(['green', 'bold'], 'Success!')} Your Studio has been created.`)\n if (!isCurrentDir) output.log(goToProjectDir)\n output.log(\n `\\nGet started by running ${styleText('cyan', devCommand)} to launch your Studio's development server`,\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 manage to open the project settings in a browser`)\n output.log(`npx sanity help to explore the CLI manual`)\n\n if (isFirstProject) {\n trace.log({selectedOption: 'yes', step: 'sendCommunityInvite'})\n\n const DISCORD_INVITE_LINK = 'https://www.sanity.io/community/join'\n\n output.log(`\\nJoin the Sanity community: ${styleText('cyan', DISCORD_INVITE_LINK)}`)\n output.log('We look forward to seeing you there!\\n')\n }\n}\n"],"names":["styleText","getCliToken","subdebug","confirm","updateProjectInitializedAt","InitError","getPostInitMCPPrompt","scaffoldAndInstall","selectTemplate","debug","promptForDatasetImport","message","default","initStudio","datasetName","defaults","displayName","isFirstProject","mcpConfigured","options","organizationId","output","outputPath","preclaim","projectId","remoteTemplateInfo","sluggedName","trace","workbench","workDir","importDataset","unattended","template","resolvedTemplate","templateName","useTypeScript","shouldImport","datasetUrl","importPrompt","log","selectedOption","step","err","pkgManager","token","ImportDatasetCommand","run","root","devCommandMap","bun","manual","npm","pnpm","yarn","devCommand","isCurrentDir","goToProjectDir","length","DISCORD_INVITE_LINK"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,WAAW,EAAeC,QAAQ,QAAqC,mBAAkB;AACjG,SAAQC,OAAO,QAAO,sBAAqB;AAG3C,SAAQC,0BAA0B,QAAO,6BAA4B;AAIrE,SAAQC,SAAS,QAAO,iBAAgB;AACxC,SAAQC,oBAAoB,QAAO,mBAAkB;AAErD,SAAQC,kBAAkB,EAAEC,cAAc,QAAO,wBAAuB;AAGxE,MAAMC,QAAQP,SAAS;AAEvB,eAAeQ,uBAAuBC,OAAgB;IACpD,OAAOR,QAAQ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B,GAAG,CACR,CAAC,2CAA2C,EAAEvC,UAAU,QAAQ,yCAAyC;IAE7G;IACAqB,OAAOkB,GAAG,CAAC;IACXlB,OAAOkB,GAAG,CAAC,CAAC,uBAAuB,CAAC;IACpClB,OAAOkB,GAAG,CAAC,CAAC,iEAAiE,CAAC;IAC9ElB,OAAOkB,GAAG,CAAC,CAAC,oEAAoE,CAAC;IACjFlB,OAAOkB,GAAG,CAAC,CAAC,oDAAoD,CAAC;IAEjE,IAAItB,gBAAgB;QAClBU,MAAMY,GAAG,CAAC;YAACC,gBAAgB;YAAOC,MAAM;QAAqB;QAE7D,MAAMiB,sBAAsB;QAE5BrC,OAAOkB,GAAG,CAAC,CAAC,6BAA6B,EAAEvC,UAAU,QAAQ0D,sBAAsB;QACnFrC,OAAOkB,GAAG,CAAC;IACb;AACF"}
@@ -1,6 +1,6 @@
1
1
  const appSanityUiTemplate = {
2
2
  dependencies: {
3
- '@sanity/ui': '^3',
3
+ '@sanity/ui': '^3.5.0',
4
4
  'styled-components': '^6.1.18'
5
5
  },
6
6
  entry: './src/App.tsx',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/actions/init/templates/appSanityUi.ts"],"sourcesContent":["import {type ProjectTemplate} from '../types.js'\n\nconst appSanityUiTemplate: ProjectTemplate = {\n dependencies: {\n '@sanity/ui': '^3',\n 'styled-components': '^6.1.18',\n },\n entry: './src/App.tsx',\n type: 'module',\n typescriptOnly: true,\n}\n\nexport default appSanityUiTemplate\n"],"names":["appSanityUiTemplate","dependencies","entry","type","typescriptOnly"],"mappings":"AAEA,MAAMA,sBAAuC;IAC3CC,cAAc;QACZ,cAAc;QACd,qBAAqB;IACvB;IACAC,OAAO;IACPC,MAAM;IACNC,gBAAgB;AAClB;AAEA,eAAeJ,oBAAmB"}
1
+ {"version":3,"sources":["../../../../src/actions/init/templates/appSanityUi.ts"],"sourcesContent":["import {type ProjectTemplate} from '../types.js'\n\nconst appSanityUiTemplate: ProjectTemplate = {\n dependencies: {\n '@sanity/ui': '^3.5.0',\n 'styled-components': '^6.1.18',\n },\n entry: './src/App.tsx',\n type: 'module',\n typescriptOnly: true,\n}\n\nexport default appSanityUiTemplate\n"],"names":["appSanityUiTemplate","dependencies","entry","type","typescriptOnly"],"mappings":"AAEA,MAAMA,sBAAuC;IAC3CC,cAAc;QACZ,cAAc;QACd,qBAAqB;IACvB;IACAC,OAAO;IACPC,MAAM;IACNC,gBAAgB;AAClB;AAEA,eAAeJ,oBAAmB"}
@@ -25,8 +25,8 @@ export default defineConfig({
25
25
  const getStartedTemplate = {
26
26
  configTemplate,
27
27
  dependencies: {
28
- '@sanity/icons': '^2.11.0',
29
- '@sanity/ui': '^2.0.0'
28
+ '@sanity/icons': '^5.0.0',
29
+ '@sanity/ui': '^3.5.0'
30
30
  },
31
31
  typescriptOnly: true
32
32
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/actions/init/templates/getStarted.ts"],"sourcesContent":["import {type ProjectTemplate} from '../types.js'\n\nconst configTemplate = `\nimport {defineConfig, isDev} from 'sanity'\nimport {visionTool} from '@sanity/vision'\nimport {structureTool} from 'sanity/structure'\nimport {schemaTypes} from './schemaTypes'\nimport {getStartedPlugin} from './plugins/sanity-plugin-tutorial'\n\nconst devOnlyPlugins = [getStartedPlugin()]\n\nexport default defineConfig({\n name: '%sourceName%',\n title: '%projectName%',\n\n projectId: '%projectId%',\n dataset: '%dataset%',\n\n plugins: [structureTool(), visionTool(), ...(isDev ? devOnlyPlugins : [])],\n\n schema: {\n types: schemaTypes,\n },\n})\n\n`\n\nconst getStartedTemplate: ProjectTemplate = {\n configTemplate,\n dependencies: {\n '@sanity/icons': '^2.11.0',\n '@sanity/ui': '^2.0.0',\n },\n typescriptOnly: true,\n}\n\nexport default getStartedTemplate\n"],"names":["configTemplate","getStartedTemplate","dependencies","typescriptOnly"],"mappings":"AAEA,MAAMA,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;AAuBxB,CAAC;AAED,MAAMC,qBAAsC;IAC1CD;IACAE,cAAc;QACZ,iBAAiB;QACjB,cAAc;IAChB;IACAC,gBAAgB;AAClB;AAEA,eAAeF,mBAAkB"}
1
+ {"version":3,"sources":["../../../../src/actions/init/templates/getStarted.ts"],"sourcesContent":["import {type ProjectTemplate} from '../types.js'\n\nconst configTemplate = `\nimport {defineConfig, isDev} from 'sanity'\nimport {visionTool} from '@sanity/vision'\nimport {structureTool} from 'sanity/structure'\nimport {schemaTypes} from './schemaTypes'\nimport {getStartedPlugin} from './plugins/sanity-plugin-tutorial'\n\nconst devOnlyPlugins = [getStartedPlugin()]\n\nexport default defineConfig({\n name: '%sourceName%',\n title: '%projectName%',\n\n projectId: '%projectId%',\n dataset: '%dataset%',\n\n plugins: [structureTool(), visionTool(), ...(isDev ? devOnlyPlugins : [])],\n\n schema: {\n types: schemaTypes,\n },\n})\n\n`\n\nconst getStartedTemplate: ProjectTemplate = {\n configTemplate,\n dependencies: {\n '@sanity/icons': '^5.0.0',\n '@sanity/ui': '^3.5.0',\n },\n typescriptOnly: true,\n}\n\nexport default getStartedTemplate\n"],"names":["configTemplate","getStartedTemplate","dependencies","typescriptOnly"],"mappings":"AAEA,MAAMA,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;AAuBxB,CAAC;AAED,MAAMC,qBAAsC;IAC1CD;IACAE,cAAc;QACZ,iBAAiB;QACjB,cAAc;IAChB;IACAC,gBAAgB;AAClB;AAEA,eAAeF,mBAAkB"}
@@ -1,5 +1,5 @@
1
1
  // Types
2
- const authorType = `import {UserIcon} from '@sanity/icons'
2
+ const authorType = `import {UserIcon} from '@sanity/icons/User'
3
3
  import {defineArrayMember, defineField, defineType} from 'sanity'
4
4
 
5
5
  export const authorType = defineType({
@@ -47,7 +47,7 @@ export const authorType = defineType({
47
47
  })
48
48
  `;
49
49
  const blockContentType = `import {defineType, defineArrayMember} from 'sanity'
50
- import {ImageIcon} from '@sanity/icons'
50
+ import {ImageIcon} from '@sanity/icons/Image'
51
51
 
52
52
  /**
53
53
  * This is the schema type for block content used in the post document type
@@ -123,7 +123,7 @@ export const blockContentType = defineType({
123
123
  ],
124
124
  })
125
125
  `;
126
- const categoryType = `import {TagIcon} from '@sanity/icons'
126
+ const categoryType = `import {TagIcon} from '@sanity/icons/Tag'
127
127
  import {defineField, defineType} from 'sanity'
128
128
 
129
129
  export const categoryType = defineType({
@@ -150,7 +150,7 @@ export const categoryType = defineType({
150
150
  ],
151
151
  })
152
152
  `;
153
- const postType = `import {DocumentTextIcon} from '@sanity/icons'
153
+ const postType = `import {DocumentTextIcon} from '@sanity/icons/DocumentText'
154
154
  import {defineArrayMember, defineField, defineType} from 'sanity'
155
155
 
156
156
  export const postType = defineType({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/actions/init/templates/nextjs/schemaTypes/blog.ts"],"sourcesContent":["// Types\n\nconst authorType = `import {UserIcon} from '@sanity/icons'\nimport {defineArrayMember, defineField, defineType} from 'sanity'\n\nexport const authorType = defineType({\n name: 'author',\n title: 'Author',\n type: 'document',\n icon: UserIcon,\n fields: [\n defineField({\n name: 'name',\n type: 'string',\n }),\n defineField({\n name: 'slug',\n type: 'slug',\n options: {\n source: 'name',\n },\n }),\n defineField({\n name: 'image',\n type: 'image',\n options: {\n hotspot: true,\n },\n }),\n defineField({\n name: 'bio',\n type: 'array',\n of: [\n defineArrayMember({\n type: 'block',\n styles: [{title: 'Normal', value: 'normal'}],\n lists: [],\n }),\n ],\n }),\n ],\n preview: {\n select: {\n title: 'name',\n media: 'image',\n },\n },\n})\n`\n\nconst blockContentType = `import {defineType, defineArrayMember} from 'sanity'\nimport {ImageIcon} from '@sanity/icons'\n\n/**\n * This is the schema type for block content used in the post document type\n * Importing this type into the studio configuration's \\`schema\\` property\n * lets you reuse it in other document types with:\n * {\n * name: 'someName',\n * title: 'Some title',\n * type: 'blockContent'\n * }\n */\n\nexport const blockContentType = defineType({\n title: 'Block Content',\n name: 'blockContent',\n type: 'array',\n of: [\n defineArrayMember({\n type: 'block',\n // Styles let you define what blocks can be marked up as. The default\n // set corresponds with HTML tags, but you can set any title or value\n // you want, and decide how you want to deal with it where you want to\n // use your content.\n styles: [\n {title: 'Normal', value: 'normal'},\n {title: 'H1', value: 'h1'},\n {title: 'H2', value: 'h2'},\n {title: 'H3', value: 'h3'},\n {title: 'H4', value: 'h4'},\n {title: 'Quote', value: 'blockquote'},\n ],\n lists: [{title: 'Bullet', value: 'bullet'}],\n // Marks let you mark up inline text in the Portable Text Editor\n marks: {\n // Decorators usually describe a single property – e.g. a typographic\n // preference or highlighting\n decorators: [\n {title: 'Strong', value: 'strong'},\n {title: 'Emphasis', value: 'em'},\n ],\n // Annotations can be any object structure – e.g. a link or a footnote.\n annotations: [\n {\n title: 'URL',\n name: 'link',\n type: 'object',\n fields: [\n {\n title: 'URL',\n name: 'href',\n type: 'url',\n },\n ],\n },\n ],\n },\n }),\n // You can add additional types here. Note that you can't use\n // primitive types such as 'string' and 'number' in the same array\n // as a block type.\n defineArrayMember({\n type: 'image',\n icon: ImageIcon,\n options: {hotspot: true},\n fields: [\n {\n name: 'alt',\n type: 'string',\n title: 'Alternative Text',\n }\n ]\n }),\n ],\n})\n`\n\nconst categoryType = `import {TagIcon} from '@sanity/icons'\nimport {defineField, defineType} from 'sanity'\n\nexport const categoryType = defineType({\n name: 'category',\n title: 'Category',\n type: 'document',\n icon: TagIcon,\n fields: [\n defineField({\n name: 'title',\n type: 'string',\n }),\n defineField({\n name: 'slug',\n type: 'slug',\n options: {\n source: 'title',\n },\n }),\n defineField({\n name: 'description',\n type: 'text',\n }),\n ],\n})\n`\n\nconst postType = `import {DocumentTextIcon} from '@sanity/icons'\nimport {defineArrayMember, defineField, defineType} from 'sanity'\n\nexport const postType = defineType({\n name: 'post',\n title: 'Post',\n type: 'document',\n icon: DocumentTextIcon,\n fields: [\n defineField({\n name: 'title',\n type: 'string',\n }),\n defineField({\n name: 'slug',\n type: 'slug',\n options: {\n source: 'title',\n },\n }),\n defineField({\n name: 'author',\n type: 'reference',\n to: {type: 'author'},\n }),\n defineField({\n name: 'mainImage',\n type: 'image',\n options: {\n hotspot: true,\n },\n fields: [\n defineField({\n name: 'alt',\n type: 'string',\n title: 'Alternative text',\n })\n ]\n }),\n defineField({\n name: 'categories',\n type: 'array',\n of: [defineArrayMember({type: 'reference', to: {type: 'category'}})],\n }),\n defineField({\n name: 'publishedAt',\n type: 'datetime',\n }),\n defineField({\n name: 'body',\n type: 'blockContent',\n }),\n ],\n preview: {\n select: {\n title: 'title',\n author: 'author.name',\n media: 'mainImage',\n },\n prepare(selection) {\n const {author} = selection\n return {...selection, subtitle: author && \\`by \\${author}\\`}\n },\n },\n})\n`\n\n// Schema definition\nexport const blogSchemaTS = `import { type SchemaTypeDefinition } from 'sanity'\n\nimport {blockContentType} from './blockContentType'\nimport {categoryType} from './categoryType'\nimport {postType} from './postType'\nimport {authorType} from './authorType'\n\nexport const schema: { types: SchemaTypeDefinition[] } = {\n types: [blockContentType, categoryType, postType, authorType],\n}\n`\n\nexport const blogSchemaJS = `import {blockContentType} from './blockContentType'\nimport {categoryType} from './categoryType'\nimport {postType} from './postType'\nimport {authorType} from './authorType'\n\nexport const schema = {\n types: [blockContentType, categoryType, postType, authorType],\n}\n`\n\nexport const blogSchemaFolder: Record<string, string> = {\n 'authorType.': authorType,\n 'blockContentType.': blockContentType,\n 'categoryType.': categoryType,\n 'postType.': postType,\n}\n"],"names":["authorType","blockContentType","categoryType","postType","blogSchemaTS","blogSchemaJS","blogSchemaFolder"],"mappings":"AAAA,QAAQ;AAER,MAAMA,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CpB,CAAC;AAED,MAAMC,mBAAmB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4E1B,CAAC;AAED,MAAMC,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BtB,CAAC;AAED,MAAMC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiElB,CAAC;AAED,oBAAoB;AACpB,OAAO,MAAMC,eAAe,CAAC;;;;;;;;;;AAU7B,CAAC,CAAA;AAED,OAAO,MAAMC,eAAe,CAAC;;;;;;;;AAQ7B,CAAC,CAAA;AAED,OAAO,MAAMC,mBAA2C;IACtD,eAAeN;IACf,qBAAqBC;IACrB,iBAAiBC;IACjB,aAAaC;AACf,EAAC"}
1
+ {"version":3,"sources":["../../../../../../src/actions/init/templates/nextjs/schemaTypes/blog.ts"],"sourcesContent":["// Types\n\nconst authorType = `import {UserIcon} from '@sanity/icons/User'\nimport {defineArrayMember, defineField, defineType} from 'sanity'\n\nexport const authorType = defineType({\n name: 'author',\n title: 'Author',\n type: 'document',\n icon: UserIcon,\n fields: [\n defineField({\n name: 'name',\n type: 'string',\n }),\n defineField({\n name: 'slug',\n type: 'slug',\n options: {\n source: 'name',\n },\n }),\n defineField({\n name: 'image',\n type: 'image',\n options: {\n hotspot: true,\n },\n }),\n defineField({\n name: 'bio',\n type: 'array',\n of: [\n defineArrayMember({\n type: 'block',\n styles: [{title: 'Normal', value: 'normal'}],\n lists: [],\n }),\n ],\n }),\n ],\n preview: {\n select: {\n title: 'name',\n media: 'image',\n },\n },\n})\n`\n\nconst blockContentType = `import {defineType, defineArrayMember} from 'sanity'\nimport {ImageIcon} from '@sanity/icons/Image'\n\n/**\n * This is the schema type for block content used in the post document type\n * Importing this type into the studio configuration's \\`schema\\` property\n * lets you reuse it in other document types with:\n * {\n * name: 'someName',\n * title: 'Some title',\n * type: 'blockContent'\n * }\n */\n\nexport const blockContentType = defineType({\n title: 'Block Content',\n name: 'blockContent',\n type: 'array',\n of: [\n defineArrayMember({\n type: 'block',\n // Styles let you define what blocks can be marked up as. The default\n // set corresponds with HTML tags, but you can set any title or value\n // you want, and decide how you want to deal with it where you want to\n // use your content.\n styles: [\n {title: 'Normal', value: 'normal'},\n {title: 'H1', value: 'h1'},\n {title: 'H2', value: 'h2'},\n {title: 'H3', value: 'h3'},\n {title: 'H4', value: 'h4'},\n {title: 'Quote', value: 'blockquote'},\n ],\n lists: [{title: 'Bullet', value: 'bullet'}],\n // Marks let you mark up inline text in the Portable Text Editor\n marks: {\n // Decorators usually describe a single property – e.g. a typographic\n // preference or highlighting\n decorators: [\n {title: 'Strong', value: 'strong'},\n {title: 'Emphasis', value: 'em'},\n ],\n // Annotations can be any object structure – e.g. a link or a footnote.\n annotations: [\n {\n title: 'URL',\n name: 'link',\n type: 'object',\n fields: [\n {\n title: 'URL',\n name: 'href',\n type: 'url',\n },\n ],\n },\n ],\n },\n }),\n // You can add additional types here. Note that you can't use\n // primitive types such as 'string' and 'number' in the same array\n // as a block type.\n defineArrayMember({\n type: 'image',\n icon: ImageIcon,\n options: {hotspot: true},\n fields: [\n {\n name: 'alt',\n type: 'string',\n title: 'Alternative Text',\n }\n ]\n }),\n ],\n})\n`\n\nconst categoryType = `import {TagIcon} from '@sanity/icons/Tag'\nimport {defineField, defineType} from 'sanity'\n\nexport const categoryType = defineType({\n name: 'category',\n title: 'Category',\n type: 'document',\n icon: TagIcon,\n fields: [\n defineField({\n name: 'title',\n type: 'string',\n }),\n defineField({\n name: 'slug',\n type: 'slug',\n options: {\n source: 'title',\n },\n }),\n defineField({\n name: 'description',\n type: 'text',\n }),\n ],\n})\n`\n\nconst postType = `import {DocumentTextIcon} from '@sanity/icons/DocumentText'\nimport {defineArrayMember, defineField, defineType} from 'sanity'\n\nexport const postType = defineType({\n name: 'post',\n title: 'Post',\n type: 'document',\n icon: DocumentTextIcon,\n fields: [\n defineField({\n name: 'title',\n type: 'string',\n }),\n defineField({\n name: 'slug',\n type: 'slug',\n options: {\n source: 'title',\n },\n }),\n defineField({\n name: 'author',\n type: 'reference',\n to: {type: 'author'},\n }),\n defineField({\n name: 'mainImage',\n type: 'image',\n options: {\n hotspot: true,\n },\n fields: [\n defineField({\n name: 'alt',\n type: 'string',\n title: 'Alternative text',\n })\n ]\n }),\n defineField({\n name: 'categories',\n type: 'array',\n of: [defineArrayMember({type: 'reference', to: {type: 'category'}})],\n }),\n defineField({\n name: 'publishedAt',\n type: 'datetime',\n }),\n defineField({\n name: 'body',\n type: 'blockContent',\n }),\n ],\n preview: {\n select: {\n title: 'title',\n author: 'author.name',\n media: 'mainImage',\n },\n prepare(selection) {\n const {author} = selection\n return {...selection, subtitle: author && \\`by \\${author}\\`}\n },\n },\n})\n`\n\n// Schema definition\nexport const blogSchemaTS = `import { type SchemaTypeDefinition } from 'sanity'\n\nimport {blockContentType} from './blockContentType'\nimport {categoryType} from './categoryType'\nimport {postType} from './postType'\nimport {authorType} from './authorType'\n\nexport const schema: { types: SchemaTypeDefinition[] } = {\n types: [blockContentType, categoryType, postType, authorType],\n}\n`\n\nexport const blogSchemaJS = `import {blockContentType} from './blockContentType'\nimport {categoryType} from './categoryType'\nimport {postType} from './postType'\nimport {authorType} from './authorType'\n\nexport const schema = {\n types: [blockContentType, categoryType, postType, authorType],\n}\n`\n\nexport const blogSchemaFolder: Record<string, string> = {\n 'authorType.': authorType,\n 'blockContentType.': blockContentType,\n 'categoryType.': categoryType,\n 'postType.': postType,\n}\n"],"names":["authorType","blockContentType","categoryType","postType","blogSchemaTS","blogSchemaJS","blogSchemaFolder"],"mappings":"AAAA,QAAQ;AAER,MAAMA,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CpB,CAAC;AAED,MAAMC,mBAAmB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4E1B,CAAC;AAED,MAAMC,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BtB,CAAC;AAED,MAAMC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiElB,CAAC;AAED,oBAAoB;AACpB,OAAO,MAAMC,eAAe,CAAC;;;;;;;;;;AAU7B,CAAC,CAAA;AAED,OAAO,MAAMC,eAAe,CAAC;;;;;;;;AAQ7B,CAAC,CAAA;AAED,OAAO,MAAMC,mBAA2C;IACtD,eAAeN;IACf,qBAAqBC;IACrB,iBAAiBC;IACjB,aAAaC;AACf,EAAC"}
@@ -58,8 +58,8 @@ const shopifyTemplate = {
58
58
  dependencies: {
59
59
  '@sanity/asset-utils': '^2.3.0',
60
60
  '@sanity/color-input': '^6.0.4',
61
- '@sanity/icons': '^3.7.4',
62
- '@sanity/ui': '^3.1.14',
61
+ '@sanity/icons': '^5.0.0',
62
+ '@sanity/ui': '^3.5.0',
63
63
  'lodash.get': '^4.4.2',
64
64
  'pluralize-esm': '^9.0.2',
65
65
  'sanity-plugin-hotspot-array': '^3.0.2',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/actions/init/templates/shopify.ts"],"sourcesContent":["import {type ProjectTemplate} from '../types.js'\n\nconst configTemplate = `\nimport {defineConfig, isDev} from 'sanity'\n\nimport {structureTool} from 'sanity/structure'\nimport {schemaTypes} from './schemaTypes'\nimport {structure} from './structure'\n\nimport {visionTool} from '@sanity/vision'\nimport {colorInput} from '@sanity/color-input'\nimport {imageHotspotArrayPlugin} from 'sanity-plugin-hotspot-array'\nimport {media, mediaAssetSource} from 'sanity-plugin-media'\nimport {customDocumentActions} from './plugins/customDocumentActions'\nimport Navbar from './components/studio/Navbar'\n\nconst devOnlyPlugins = [visionTool()]\n\nexport default defineConfig({\n name: '%sourceName%',\n title: '%projectName%',\n\n projectId: '%projectId%',\n dataset: '%dataset%',\n\n plugins: [\n structureTool({structure}),\n colorInput(),\n imageHotspotArrayPlugin(),\n customDocumentActions(),\n media(),\n ...(isDev ? devOnlyPlugins : []),\n ],\n\n schema: {\n types: schemaTypes,\n },\n\n form: {\n file: {\n assetSources: (previousAssetSources) => {\n return previousAssetSources.filter((assetSource) => assetSource !== mediaAssetSource)\n },\n },\n image: {\n assetSources: (previousAssetSources) => {\n return previousAssetSources.filter((assetSource) => assetSource === mediaAssetSource)\n },\n },\n },\n\n studio: {\n components: {\n navbar: Navbar,\n },\n },\n})`\n\nconst shopifyTemplate: ProjectTemplate = {\n configTemplate,\n dependencies: {\n '@sanity/asset-utils': '^2.3.0',\n '@sanity/color-input': '^6.0.4',\n '@sanity/icons': '^3.7.4',\n '@sanity/ui': '^3.1.14',\n 'lodash.get': '^4.4.2',\n 'pluralize-esm': '^9.0.2',\n 'sanity-plugin-hotspot-array': '^3.0.2',\n 'sanity-plugin-media': '^4.1.1',\n slug: '^8.2.2',\n },\n devDependencies: {\n '@portabletext/types': '^2.0.2',\n '@types/lodash.get': '^4.4.7',\n '@types/slug': '^5.0.3',\n },\n}\nexport default shopifyTemplate\n"],"names":["configTemplate","shopifyTemplate","dependencies","slug","devDependencies"],"mappings":"AAEA,MAAMA,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsDtB,CAAC;AAEH,MAAMC,kBAAmC;IACvCD;IACAE,cAAc;QACZ,uBAAuB;QACvB,uBAAuB;QACvB,iBAAiB;QACjB,cAAc;QACd,cAAc;QACd,iBAAiB;QACjB,+BAA+B;QAC/B,uBAAuB;QACvBC,MAAM;IACR;IACAC,iBAAiB;QACf,uBAAuB;QACvB,qBAAqB;QACrB,eAAe;IACjB;AACF;AACA,eAAeH,gBAAe"}
1
+ {"version":3,"sources":["../../../../src/actions/init/templates/shopify.ts"],"sourcesContent":["import {type ProjectTemplate} from '../types.js'\n\nconst configTemplate = `\nimport {defineConfig, isDev} from 'sanity'\n\nimport {structureTool} from 'sanity/structure'\nimport {schemaTypes} from './schemaTypes'\nimport {structure} from './structure'\n\nimport {visionTool} from '@sanity/vision'\nimport {colorInput} from '@sanity/color-input'\nimport {imageHotspotArrayPlugin} from 'sanity-plugin-hotspot-array'\nimport {media, mediaAssetSource} from 'sanity-plugin-media'\nimport {customDocumentActions} from './plugins/customDocumentActions'\nimport Navbar from './components/studio/Navbar'\n\nconst devOnlyPlugins = [visionTool()]\n\nexport default defineConfig({\n name: '%sourceName%',\n title: '%projectName%',\n\n projectId: '%projectId%',\n dataset: '%dataset%',\n\n plugins: [\n structureTool({structure}),\n colorInput(),\n imageHotspotArrayPlugin(),\n customDocumentActions(),\n media(),\n ...(isDev ? devOnlyPlugins : []),\n ],\n\n schema: {\n types: schemaTypes,\n },\n\n form: {\n file: {\n assetSources: (previousAssetSources) => {\n return previousAssetSources.filter((assetSource) => assetSource !== mediaAssetSource)\n },\n },\n image: {\n assetSources: (previousAssetSources) => {\n return previousAssetSources.filter((assetSource) => assetSource === mediaAssetSource)\n },\n },\n },\n\n studio: {\n components: {\n navbar: Navbar,\n },\n },\n})`\n\nconst shopifyTemplate: ProjectTemplate = {\n configTemplate,\n dependencies: {\n '@sanity/asset-utils': '^2.3.0',\n '@sanity/color-input': '^6.0.4',\n '@sanity/icons': '^5.0.0',\n '@sanity/ui': '^3.5.0',\n 'lodash.get': '^4.4.2',\n 'pluralize-esm': '^9.0.2',\n 'sanity-plugin-hotspot-array': '^3.0.2',\n 'sanity-plugin-media': '^4.1.1',\n slug: '^8.2.2',\n },\n devDependencies: {\n '@portabletext/types': '^2.0.2',\n '@types/lodash.get': '^4.4.7',\n '@types/slug': '^5.0.3',\n },\n}\nexport default shopifyTemplate\n"],"names":["configTemplate","shopifyTemplate","dependencies","slug","devDependencies"],"mappings":"AAEA,MAAMA,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsDtB,CAAC;AAEH,MAAMC,kBAAmC;IACvCD;IACAE,cAAc;QACZ,uBAAuB;QACvB,uBAAuB;QACvB,iBAAiB;QACjB,cAAc;QACd,cAAc;QACd,iBAAiB;QACjB,+BAA+B;QAC/B,uBAAuB;QACvBC,MAAM;IACR;IACAC,iBAAiB;QACf,uBAAuB;QACvB,qBAAqB;QACrB,eAAe;IACjB;AACF;AACA,eAAeH,gBAAe"}
@@ -35,8 +35,8 @@ const shopifyTemplate = {
35
35
  configTemplate,
36
36
  dependencies: {
37
37
  '@portabletext/toolkit': '^2.0.1',
38
- '@sanity/icons': '^3.7.4',
39
- '@sanity/ui': '^3.1.14',
38
+ '@sanity/icons': '^5.0.0',
39
+ '@sanity/ui': '^3.5.0',
40
40
  '@types/lodash.get': '^4.4.7',
41
41
  'lodash.get': '^4.4.2',
42
42
  'pluralize-esm': '^9.0.4',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/actions/init/templates/shopifyOnline.ts"],"sourcesContent":["import {type ProjectTemplate} from '../types.js'\n\nconst configTemplate = `\nimport {shopifyAssets} from 'sanity-plugin-shopify-assets'\nimport {defineConfig, isDev} from 'sanity'\nimport {structureTool} from 'sanity/structure'\nimport {visionTool} from '@sanity/vision'\nimport {shopifyDocumentActions} from './plugins/shopifyDocumentActions'\nimport {schemaTypes} from './schemaTypes'\nimport {structure} from './structure'\nimport {SHOPIFY_STORE_ID} from './constants'\n\nconst devOnlyPlugins = [visionTool()]\n\nexport default defineConfig({\n name: '%sourceName%',\n title: '%projectName%',\n\n projectId: '%projectId%',\n dataset: '%dataset%',\n\n plugins: [\n structureTool({structure}),\n shopifyDocumentActions(),\n shopifyAssets({\n shopifyDomain: SHOPIFY_STORE_ID,\n }),\n ...(isDev ? devOnlyPlugins : []),\n ],\n\n schema: {\n types: schemaTypes,\n },\n})\n`\n\nconst shopifyTemplate: ProjectTemplate = {\n configTemplate,\n dependencies: {\n '@portabletext/toolkit': '^2.0.1',\n '@sanity/icons': '^3.7.4',\n '@sanity/ui': '^3.1.14',\n '@types/lodash.get': '^4.4.7',\n 'lodash.get': '^4.4.2',\n 'pluralize-esm': '^9.0.4',\n 'sanity-plugin-shopify-assets': '^1.1.0',\n },\n typescriptOnly: true,\n}\nexport default shopifyTemplate\n"],"names":["configTemplate","shopifyTemplate","dependencies","typescriptOnly"],"mappings":"AAEA,MAAMA,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCxB,CAAC;AAED,MAAMC,kBAAmC;IACvCD;IACAE,cAAc;QACZ,yBAAyB;QACzB,iBAAiB;QACjB,cAAc;QACd,qBAAqB;QACrB,cAAc;QACd,iBAAiB;QACjB,gCAAgC;IAClC;IACAC,gBAAgB;AAClB;AACA,eAAeF,gBAAe"}
1
+ {"version":3,"sources":["../../../../src/actions/init/templates/shopifyOnline.ts"],"sourcesContent":["import {type ProjectTemplate} from '../types.js'\n\nconst configTemplate = `\nimport {shopifyAssets} from 'sanity-plugin-shopify-assets'\nimport {defineConfig, isDev} from 'sanity'\nimport {structureTool} from 'sanity/structure'\nimport {visionTool} from '@sanity/vision'\nimport {shopifyDocumentActions} from './plugins/shopifyDocumentActions'\nimport {schemaTypes} from './schemaTypes'\nimport {structure} from './structure'\nimport {SHOPIFY_STORE_ID} from './constants'\n\nconst devOnlyPlugins = [visionTool()]\n\nexport default defineConfig({\n name: '%sourceName%',\n title: '%projectName%',\n\n projectId: '%projectId%',\n dataset: '%dataset%',\n\n plugins: [\n structureTool({structure}),\n shopifyDocumentActions(),\n shopifyAssets({\n shopifyDomain: SHOPIFY_STORE_ID,\n }),\n ...(isDev ? devOnlyPlugins : []),\n ],\n\n schema: {\n types: schemaTypes,\n },\n})\n`\n\nconst shopifyTemplate: ProjectTemplate = {\n configTemplate,\n dependencies: {\n '@portabletext/toolkit': '^2.0.1',\n '@sanity/icons': '^5.0.0',\n '@sanity/ui': '^3.5.0',\n '@types/lodash.get': '^4.4.7',\n 'lodash.get': '^4.4.2',\n 'pluralize-esm': '^9.0.4',\n 'sanity-plugin-shopify-assets': '^1.1.0',\n },\n typescriptOnly: true,\n}\nexport default shopifyTemplate\n"],"names":["configTemplate","shopifyTemplate","dependencies","typescriptOnly"],"mappings":"AAEA,MAAMA,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCxB,CAAC;AAED,MAAMC,kBAAmC;IACvCD;IACAE,cAAc;QACZ,yBAAyB;QACzB,iBAAiB;QACjB,cAAc;QACd,qBAAqB;QACrB,cAAc;QACd,iBAAiB;QACjB,gCAAgC;IAClC;IACAC,gBAAgB;AAClB;AACA,eAAeF,gBAAe"}
@@ -80,7 +80,7 @@ const sanitizeIconPath = new URL('sanitizeIcon.js', import.meta.url).href;
80
80
  spin.info('Manifest creation skipped: no icon or title found in app configuration');
81
81
  return undefined;
82
82
  }
83
- const slug = isWorkbenchApp(app) ? app.slug : undefined;
83
+ const workbench = isWorkbenchApp(app) ? app : undefined;
84
84
  const manifest = coreAppManifestSchema.parse({
85
85
  version: '1',
86
86
  ...icon ? {
@@ -89,14 +89,14 @@ const sanitizeIconPath = new URL('sanitizeIcon.js', import.meta.url).href;
89
89
  ...app.title ? {
90
90
  title: app.title
91
91
  } : {},
92
- ...app.group ? {
93
- group: app.group
92
+ ...workbench?.group ? {
93
+ group: workbench.group
94
94
  } : {},
95
- ...app.priority === undefined ? {} : {
96
- priority: app.priority
95
+ ...workbench?.priority === undefined ? {} : {
96
+ priority: workbench.priority
97
97
  },
98
- ...slug ? {
99
- slug
98
+ ...workbench?.slug ? {
99
+ slug: workbench.slug
100
100
  } : {}
101
101
  });
102
102
  spin.succeed(`Extracted manifest`);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/manifest/extractCoreAppManifest.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\nimport {relative, resolve} from 'node:path'\n\nimport {doImport, getCliConfigUncached} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\n\nimport {type sanitizeIcon as sanitizeIconFn} from './sanitizeIcon.js'\nimport {type CoreAppManifest, coreAppManifestSchema} from './types.js'\n\ninterface ExtractCoreAppManifestOptions {\n workDir: string\n}\n\n/**\n * The title change a deploy would sync from the manifest to the user\n * application, or null when the titles already match (or none is set).\n *\n * @internal\n */\nexport function resolveTitleUpdate(\n manifest: CoreAppManifest | undefined,\n application: {title: string | null},\n): {from: string | null; to: string} | null {\n if (manifest?.title === undefined || manifest.title === application.title) {\n return null\n }\n return {from: application.title, to: manifest.title}\n}\n\nconst sanitizeIconPath = new URL('sanitizeIcon.js', import.meta.url).href\n\n/**\n * Lazy-load {@link sanitizeIconFn} so `isomorphic-dompurify` (and its jsdom\n * dependency) stays out of the CLI's eager import graph. The studio manifest\n * resolver lazy-loads its icon machinery for the same reason; this path runs in\n * the main process (not the manifest worker), so only an app deploy that\n * actually has an icon pays the cost.\n */\nasync function lazySanitizeIcon(): Promise<typeof sanitizeIconFn> {\n const mod = await doImport(sanitizeIconPath)\n return mod.sanitizeIcon\n}\n\n/**\n * Resolves app.icon from config (a file path) to a sanitized SVG string. Used\n * both for the manifest and, on deploy, for the icon shipped to Brett — the\n * manifest expects the SVG inline, not a path.\n *\n * The file is sanitized through the same allowlist as the studio manifest's\n * icon resolver (see {@link lazySanitizeIcon}) so both manifest paths inline the\n * same trusted subset of SVG markup.\n * @internal\n */\nexport async function readIconFromPath(workDir: string, iconPath: string): Promise<string> {\n const resolvedPath = resolve(workDir, iconPath)\n const pathRelativeToWorkDir = relative(workDir, resolvedPath)\n if (pathRelativeToWorkDir.startsWith('..')) {\n throw new Error(\n `Icon path \"${iconPath}\" resolves outside the project directory and is not allowed.`,\n )\n }\n\n let content: string\n try {\n content = await readFile(resolvedPath, 'utf8')\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n throw new Error(\n `Could not read icon file at \"${iconPath}\" (resolved: ${resolvedPath}): ${message}`,\n {cause: err},\n )\n }\n\n const trimmed = content.trim()\n if (!/<svg[\\s>]/i.test(trimmed)) {\n throw new Error(\n `Icon file at \"${iconPath}\" does not contain an SVG element. App manifest icons must be SVG files.`,\n )\n }\n\n const sanitizeIcon = await lazySanitizeIcon()\n return sanitizeIcon(trimmed)\n}\n\n/**\n * Unlike studio manifest extraction, skips schema/tool parsing. The config's\n * `app.icon` is a file path; its content is read and inlined in the manifest.\n */\nexport async function extractCoreAppManifest(\n options: ExtractCoreAppManifestOptions,\n): Promise<CoreAppManifest | undefined> {\n const {workDir} = options\n const {app} = await getCliConfigUncached(workDir)\n if (!app) {\n return undefined\n }\n\n const spin = spinner('Extracting manifest').start()\n\n try {\n let icon: string | undefined\n if (app.icon) {\n icon = await readIconFromPath(workDir, app.icon)\n }\n\n if (!icon && !app.title) {\n spin.info('Manifest creation skipped: no icon or title found in app configuration')\n return undefined\n }\n\n const slug = isWorkbenchApp(app) ? app.slug : undefined\n\n const manifest: CoreAppManifest = coreAppManifestSchema.parse({\n version: '1',\n ...(icon ? {icon} : {}),\n ...(app.title ? {title: app.title} : {}),\n ...(app.group ? {group: app.group} : {}),\n ...(app.priority === undefined ? {} : {priority: app.priority}),\n ...(slug ? {slug} : {}),\n })\n\n spin.succeed(`Extracted manifest`)\n\n return manifest\n } catch (err) {\n const message = getErrorMessage(err)\n spin.fail(message)\n throw err\n }\n}\n"],"names":["readFile","relative","resolve","doImport","getCliConfigUncached","getErrorMessage","spinner","isWorkbenchApp","coreAppManifestSchema","resolveTitleUpdate","manifest","application","title","undefined","from","to","sanitizeIconPath","URL","url","href","lazySanitizeIcon","mod","sanitizeIcon","readIconFromPath","workDir","iconPath","resolvedPath","pathRelativeToWorkDir","startsWith","Error","content","err","message","String","cause","trimmed","trim","test","extractCoreAppManifest","options","app","spin","start","icon","info","slug","parse","version","group","priority","succeed","fail"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AACzC,SAAQC,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAE3C,SAAQC,QAAQ,EAAEC,oBAAoB,QAAO,mBAAkB;AAC/D,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,cAAc,QAAO,wB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AACf,OAAO,EAAC,GAAGe;IAClB,MAAM,EAACC,GAAG,EAAC,GAAG,MAAMpC,qBAAqBoB;IACzC,IAAI,CAACgB,KAAK;QACR,OAAO3B;IACT;IAEA,MAAM4B,OAAOnC,QAAQ,uBAAuBoC,KAAK;IAEjD,IAAI;QACF,IAAIC;QACJ,IAAIH,IAAIG,IAAI,EAAE;YACZA,OAAO,MAAMpB,iBAAiBC,SAASgB,IAAIG,IAAI;QACjD;QAEA,IAAI,CAACA,QAAQ,CAACH,IAAI5B,KAAK,EAAE;YACvB6B,KAAKG,IAAI,CAAC;YACV,OAAO/B;QACT;QAEA,MAAMgC,OAAOtC,eAAeiC,OAAOA,IAAIK,IAAI,GAAGhC;QAE9C,MAAMH,WAA4BF,sBAAsBsC,KAAK,CAAC;YAC5DC,SAAS;YACT,GAAIJ,OAAO;gBAACA;YAAI,IAAI,CAAC,CAAC;YACtB,GAAIH,IAAI5B,KAAK,GAAG;gBAACA,OAAO4B,IAAI5B,KAAK;YAAA,IAAI,CAAC,CAAC;YACvC,GAAI4B,IAAIQ,KAAK,GAAG;gBAACA,OAAOR,IAAIQ,KAAK;YAAA,IAAI,CAAC,CAAC;YACvC,GAAIR,IAAIS,QAAQ,KAAKpC,YAAY,CAAC,IAAI;gBAACoC,UAAUT,IAAIS,QAAQ;YAAA,CAAC;YAC9D,GAAIJ,OAAO;gBAACA;YAAI,IAAI,CAAC,CAAC;QACxB;QAEAJ,KAAKS,OAAO,CAAC,CAAC,kBAAkB,CAAC;QAEjC,OAAOxC;IACT,EAAE,OAAOqB,KAAK;QACZ,MAAMC,UAAU3B,gBAAgB0B;QAChCU,KAAKU,IAAI,CAACnB;QACV,MAAMD;IACR;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/manifest/extractCoreAppManifest.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\nimport {relative, resolve} from 'node:path'\n\nimport {doImport, getCliConfigUncached} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\n\nimport {type sanitizeIcon as sanitizeIconFn} from './sanitizeIcon.js'\nimport {type CoreAppManifest, coreAppManifestSchema} from './types.js'\n\ninterface ExtractCoreAppManifestOptions {\n workDir: string\n}\n\n/**\n * The title change a deploy would sync from the manifest to the user\n * application, or null when the titles already match (or none is set).\n *\n * @internal\n */\nexport function resolveTitleUpdate(\n manifest: CoreAppManifest | undefined,\n application: {title: string | null},\n): {from: string | null; to: string} | null {\n if (manifest?.title === undefined || manifest.title === application.title) {\n return null\n }\n return {from: application.title, to: manifest.title}\n}\n\nconst sanitizeIconPath = new URL('sanitizeIcon.js', import.meta.url).href\n\n/**\n * Lazy-load {@link sanitizeIconFn} so `isomorphic-dompurify` (and its jsdom\n * dependency) stays out of the CLI's eager import graph. The studio manifest\n * resolver lazy-loads its icon machinery for the same reason; this path runs in\n * the main process (not the manifest worker), so only an app deploy that\n * actually has an icon pays the cost.\n */\nasync function lazySanitizeIcon(): Promise<typeof sanitizeIconFn> {\n const mod = await doImport(sanitizeIconPath)\n return mod.sanitizeIcon\n}\n\n/**\n * Resolves app.icon from config (a file path) to a sanitized SVG string. Used\n * both for the manifest and, on deploy, for the icon shipped to Brett — the\n * manifest expects the SVG inline, not a path.\n *\n * The file is sanitized through the same allowlist as the studio manifest's\n * icon resolver (see {@link lazySanitizeIcon}) so both manifest paths inline the\n * same trusted subset of SVG markup.\n * @internal\n */\nexport async function readIconFromPath(workDir: string, iconPath: string): Promise<string> {\n const resolvedPath = resolve(workDir, iconPath)\n const pathRelativeToWorkDir = relative(workDir, resolvedPath)\n if (pathRelativeToWorkDir.startsWith('..')) {\n throw new Error(\n `Icon path \"${iconPath}\" resolves outside the project directory and is not allowed.`,\n )\n }\n\n let content: string\n try {\n content = await readFile(resolvedPath, 'utf8')\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n throw new Error(\n `Could not read icon file at \"${iconPath}\" (resolved: ${resolvedPath}): ${message}`,\n {cause: err},\n )\n }\n\n const trimmed = content.trim()\n if (!/<svg[\\s>]/i.test(trimmed)) {\n throw new Error(\n `Icon file at \"${iconPath}\" does not contain an SVG element. App manifest icons must be SVG files.`,\n )\n }\n\n const sanitizeIcon = await lazySanitizeIcon()\n return sanitizeIcon(trimmed)\n}\n\n/**\n * Unlike studio manifest extraction, skips schema/tool parsing. The config's\n * `app.icon` is a file path; its content is read and inlined in the manifest.\n */\nexport async function extractCoreAppManifest(\n options: ExtractCoreAppManifestOptions,\n): Promise<CoreAppManifest | undefined> {\n const {workDir} = options\n const {app} = await getCliConfigUncached(workDir)\n if (!app) {\n return undefined\n }\n\n const spin = spinner('Extracting manifest').start()\n\n try {\n let icon: string | undefined\n if (app.icon) {\n icon = await readIconFromPath(workDir, app.icon)\n }\n\n if (!icon && !app.title) {\n spin.info('Manifest creation skipped: no icon or title found in app configuration')\n return undefined\n }\n\n const workbench = isWorkbenchApp(app) ? app : undefined\n\n const manifest: CoreAppManifest = coreAppManifestSchema.parse({\n version: '1',\n ...(icon ? {icon} : {}),\n ...(app.title ? {title: app.title} : {}),\n ...(workbench?.group ? {group: workbench.group} : {}),\n ...(workbench?.priority === undefined ? {} : {priority: workbench.priority}),\n ...(workbench?.slug ? {slug: workbench.slug} : {}),\n })\n\n spin.succeed(`Extracted manifest`)\n\n return manifest\n } catch (err) {\n const message = getErrorMessage(err)\n spin.fail(message)\n throw err\n }\n}\n"],"names":["readFile","relative","resolve","doImport","getCliConfigUncached","getErrorMessage","spinner","isWorkbenchApp","coreAppManifestSchema","resolveTitleUpdate","manifest","application","title","undefined","from","to","sanitizeIconPath","URL","url","href","lazySanitizeIcon","mod","sanitizeIcon","readIconFromPath","workDir","iconPath","resolvedPath","pathRelativeToWorkDir","startsWith","Error","content","err","message","String","cause","trimmed","trim","test","extractCoreAppManifest","options","app","spin","start","icon","info","workbench","parse","version","group","priority","slug","succeed","fail"],"mappings":"AAAA,SAAQA,QAAQ,Q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