@sanity/cli 3.49.0 → 3.50.1-canary.9

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.
@@ -22433,7 +22433,7 @@ function resolveConsent({ env }) {
22433
22433
  store: getUserConfig(),
22434
22434
  key: TELEMETRY_CONSENT_CONFIG_KEY,
22435
22435
  ttl: FIVE_MINUTES,
22436
- fetchValue: () => client2.request({ uri: "/intake/telemetry-status" }),
22436
+ fetchValue: () => client2.request({ uri: "/intake/telemetry-status", tag: "telemetry-consent.cli" }),
22437
22437
  onRevalidate() {
22438
22438
  debug$1("Revalidating cached telemetry consent status...");
22439
22439
  },
@@ -33215,12 +33215,14 @@ function requireLib$1() {
33215
33215
  }
33216
33216
  const Errors = Object.assign({}, ParseErrorEnum(ModuleErrors), ParseErrorEnum(StandardErrors), ParseErrorEnum(StrictModeErrors), ParseErrorEnum`pipelineOperator`(PipelineOperatorErrors)), {
33217
33217
  defineProperty: defineProperty2
33218
- } = Object, toUnenumerable = (object, key2) => defineProperty2(object, key2, {
33219
- enumerable: !1,
33220
- value: object[key2]
33221
- });
33218
+ } = Object, toUnenumerable = (object, key2) => {
33219
+ object && defineProperty2(object, key2, {
33220
+ enumerable: !1,
33221
+ value: object[key2]
33222
+ });
33223
+ };
33222
33224
  function toESTreeLocation(node2) {
33223
- return node2.loc.start && toUnenumerable(node2.loc.start, "index"), node2.loc.end && toUnenumerable(node2.loc.end, "index"), node2;
33225
+ return toUnenumerable(node2.loc.start, "index"), toUnenumerable(node2.loc.end, "index"), node2;
33224
33226
  }
33225
33227
  var estree = (superClass) => class extends superClass {
33226
33228
  parse() {
@@ -34515,7 +34517,7 @@ function requireLib$1() {
34515
34517
  default:
34516
34518
  if (ch >= 48 && ch <= 55) {
34517
34519
  const startPos = pos2 - 1;
34518
- let octalStr = input2.slice(startPos, pos2 + 2).match(/^[0-7]+/)[0], octal = parseInt(octalStr, 8);
34520
+ let octalStr = /^[0-7]+/.exec(input2.slice(startPos, pos2 + 2))[0], octal = parseInt(octalStr, 8);
34519
34521
  octal > 255 && (octalStr = octalStr.slice(0, -1), octal = parseInt(octalStr, 8)), pos2 += octalStr.length - 1;
34520
34522
  const next = input2.charCodeAt(pos2);
34521
34523
  if (octalStr !== "0" || next === 56 || next === 57) {
@@ -36439,7 +36441,7 @@ function requireLib$1() {
36439
36441
  }
36440
36442
  forwardNoArrowParamsConversionAt(node2, parse4) {
36441
36443
  let result;
36442
- return this.state.noArrowParamsConversionAt.indexOf(node2.start) !== -1 ? (this.state.noArrowParamsConversionAt.push(this.state.start), result = parse4(), this.state.noArrowParamsConversionAt.pop()) : result = parse4(), result;
36444
+ return this.state.noArrowParamsConversionAt.includes(node2.start) ? (this.state.noArrowParamsConversionAt.push(this.state.start), result = parse4(), this.state.noArrowParamsConversionAt.pop()) : result = parse4(), result;
36443
36445
  }
36444
36446
  parseParenItem(node2, startLoc) {
36445
36447
  const newNode = super.parseParenItem(node2, startLoc);
@@ -36725,20 +36727,20 @@ function requireLib$1() {
36725
36727
  return this.match(14) || super.shouldParseArrow(params);
36726
36728
  }
36727
36729
  setArrowFunctionParameters(node2, params) {
36728
- this.state.noArrowParamsConversionAt.indexOf(node2.start) !== -1 ? node2.params = params : super.setArrowFunctionParameters(node2, params);
36730
+ this.state.noArrowParamsConversionAt.includes(node2.start) ? node2.params = params : super.setArrowFunctionParameters(node2, params);
36729
36731
  }
36730
36732
  checkParams(node2, allowDuplicates, isArrowFunction, strictModeChanged = !0) {
36731
- if (!(isArrowFunction && this.state.noArrowParamsConversionAt.indexOf(node2.start) !== -1)) {
36733
+ if (!(isArrowFunction && this.state.noArrowParamsConversionAt.includes(node2.start))) {
36732
36734
  for (let i2 = 0; i2 < node2.params.length; i2++)
36733
36735
  this.isThisParam(node2.params[i2]) && i2 > 0 && this.raise(FlowErrors.ThisParamMustBeFirst, node2.params[i2]);
36734
36736
  super.checkParams(node2, allowDuplicates, isArrowFunction, strictModeChanged);
36735
36737
  }
36736
36738
  }
36737
36739
  parseParenAndDistinguishExpression(canBeArrow) {
36738
- return super.parseParenAndDistinguishExpression(canBeArrow && this.state.noArrowAt.indexOf(this.state.start) === -1);
36740
+ return super.parseParenAndDistinguishExpression(canBeArrow && !this.state.noArrowAt.includes(this.state.start));
36739
36741
  }
36740
36742
  parseSubscripts(base2, startLoc, noCalls) {
36741
- if (base2.type === "Identifier" && base2.name === "async" && this.state.noArrowAt.indexOf(startLoc.index) !== -1) {
36743
+ if (base2.type === "Identifier" && base2.name === "async" && this.state.noArrowAt.includes(startLoc.index)) {
36742
36744
  this.next();
36743
36745
  const node2 = this.startNodeAt(startLoc);
36744
36746
  node2.callee = base2, node2.arguments = super.parseCallExpressionArguments(11, !1), base2 = this.finishNode(node2, "CallExpression");
@@ -38091,7 +38093,7 @@ function requireLib$1() {
38091
38093
  if (!tokenIsIdentifier(this.state.type) && this.state.type !== 58 && this.state.type !== 75)
38092
38094
  return;
38093
38095
  const modifier = this.state.value;
38094
- if (allowedModifiers.indexOf(modifier) !== -1) {
38096
+ if (allowedModifiers.includes(modifier)) {
38095
38097
  if (stopOnStartOfClassStaticBlock && this.tsIsStartOfStaticBlocks())
38096
38098
  return;
38097
38099
  if (this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this)))
@@ -39349,12 +39351,15 @@ function requireLib$1() {
39349
39351
  return type2 && (param.typeAnnotation = type2, this.resetEndLocation(param)), param;
39350
39352
  }
39351
39353
  tsInAmbientContext(cb) {
39352
- const oldIsAmbientContext = this.state.isAmbientContext;
39353
- this.state.isAmbientContext = !0;
39354
+ const {
39355
+ isAmbientContext: oldIsAmbientContext,
39356
+ strict: oldStrict
39357
+ } = this.state;
39358
+ this.state.isAmbientContext = !0, this.state.strict = !1;
39354
39359
  try {
39355
39360
  return cb();
39356
39361
  } finally {
39357
- this.state.isAmbientContext = oldIsAmbientContext;
39362
+ this.state.isAmbientContext = oldIsAmbientContext, this.state.strict = oldStrict;
39358
39363
  }
39359
39364
  }
39360
39365
  parseClass(node2, isStatement, optionalId) {
@@ -40241,8 +40246,8 @@ function requireLib$1() {
40241
40246
  return this.parseLiteral(value, "DecimalLiteral");
40242
40247
  }
40243
40248
  parseRegExpLiteral(value) {
40244
- const node2 = this.parseLiteral(value.value, "RegExpLiteral");
40245
- return node2.pattern = value.pattern, node2.flags = value.flags, node2;
40249
+ const node2 = this.startNode();
40250
+ return this.addExtra(node2, "raw", this.input.slice(node2.start, this.state.end)), node2.pattern = value.pattern, node2.flags = value.flags, this.next(), this.finishNode(node2, "RegExpLiteral");
40246
40251
  }
40247
40252
  parseBooleanLiteral(value) {
40248
40253
  const node2 = this.startNode();
@@ -40911,9 +40916,9 @@ function requireLib$1() {
40911
40916
  const next = this.nextTokenStart(), nextCh = this.codePointAtPos(next);
40912
40917
  return this.chStartsBindingPattern(nextCh) || this.chStartsBindingIdentifier(nextCh, next);
40913
40918
  }
40914
- hasInLineFollowingBindingIdentifier() {
40919
+ hasInLineFollowingBindingIdentifierOrBrace() {
40915
40920
  const next = this.nextTokenInLineStart(), nextCh = this.codePointAtPos(next);
40916
- return this.chStartsBindingIdentifier(nextCh, next);
40921
+ return nextCh === 123 || this.chStartsBindingIdentifier(nextCh, next);
40917
40922
  }
40918
40923
  startsUsingForOf() {
40919
40924
  const {
@@ -40985,7 +40990,7 @@ function requireLib$1() {
40985
40990
  return this.isAwaitAllowed() ? allowDeclaration || this.raise(Errors.UnexpectedLexicalDeclaration, node2) : this.raise(Errors.AwaitUsingNotInAsyncContext, node2), this.next(), this.parseVarStatement(node2, "await using");
40986
40991
  break;
40987
40992
  case 107:
40988
- if (this.state.containsEsc || !this.hasInLineFollowingBindingIdentifier())
40993
+ if (this.state.containsEsc || !this.hasInLineFollowingBindingIdentifierOrBrace())
40989
40994
  break;
40990
40995
  return this.expectPlugin("explicitResourceManagement"), !this.scope.inModule && this.scope.inTopLevel ? this.raise(Errors.UnexpectedUsingDeclaration, this.state.startLoc) : allowDeclaration || this.raise(Errors.UnexpectedLexicalDeclaration, this.state.startLoc), this.parseVarStatement(node2, "using");
40991
40996
  case 100: {
@@ -41265,7 +41270,7 @@ function requireLib$1() {
41265
41270
  }
41266
41271
  parseVarId(decl, kind) {
41267
41272
  const id = this.parseBindingAtom();
41268
- this.checkLVal(id, {
41273
+ (kind === "using" || kind === "await using") && (id.type === "ArrayPattern" || id.type === "ObjectPattern") && this.raise(Errors.UsingDeclarationHasBindingPattern, id.loc.start), this.checkLVal(id, {
41269
41274
  in: {
41270
41275
  type: "VariableDeclarator"
41271
41276
  },
@@ -41661,7 +41666,7 @@ function requireLib$1() {
41661
41666
  }
41662
41667
  parseModuleExportName() {
41663
41668
  if (this.match(133)) {
41664
- const result = this.parseStringLiteral(this.state.value), surrogate = result.value.match(loneSurrogate);
41669
+ const result = this.parseStringLiteral(this.state.value), surrogate = loneSurrogate.exec(result.value);
41665
41670
  return surrogate && this.raise(Errors.ModuleExportNameHasLoneSurrogate, result, {
41666
41671
  surrogateCharCode: surrogate[0].charCodeAt(0)
41667
41672
  }), result;
@@ -43639,19 +43644,17 @@ The default dataset configuration has a public dataset named "production".`;
43639
43644
  }
43640
43645
  const authorTS = `import {defineField, defineType} from 'sanity'
43641
43646
 
43642
- export default defineType({
43647
+ export const authorType = defineType({
43643
43648
  name: 'author',
43644
43649
  title: 'Author',
43645
43650
  type: 'document',
43646
43651
  fields: [
43647
43652
  defineField({
43648
43653
  name: 'name',
43649
- title: 'Name',
43650
43654
  type: 'string',
43651
43655
  }),
43652
43656
  defineField({
43653
43657
  name: 'slug',
43654
- title: 'Slug',
43655
43658
  type: 'slug',
43656
43659
  options: {
43657
43660
  source: 'name',
@@ -43660,7 +43663,6 @@ export default defineType({
43660
43663
  }),
43661
43664
  defineField({
43662
43665
  name: 'image',
43663
- title: 'Image',
43664
43666
  type: 'image',
43665
43667
  options: {
43666
43668
  hotspot: true,
@@ -43675,11 +43677,9 @@ export default defineType({
43675
43677
  }),
43676
43678
  defineField({
43677
43679
  name: 'bio',
43678
- title: 'Bio',
43679
43680
  type: 'array',
43680
43681
  of: [
43681
43682
  {
43682
- title: 'Block',
43683
43683
  type: 'block',
43684
43684
  styles: [{title: 'Normal', value: 'normal'}],
43685
43685
  lists: [],
@@ -43694,19 +43694,17 @@ export default defineType({
43694
43694
  },
43695
43695
  },
43696
43696
  })
43697
- `, authorJS = `export const author = {
43697
+ `, authorJS = `export const authorType = {
43698
43698
  name: 'author',
43699
43699
  title: 'Author',
43700
43700
  type: 'document',
43701
43701
  fields: [
43702
43702
  {
43703
43703
  name: 'name',
43704
- title: 'Name',
43705
43704
  type: 'string',
43706
43705
  },
43707
43706
  {
43708
43707
  name: 'slug',
43709
- title: 'Slug',
43710
43708
  type: 'slug',
43711
43709
  options: {
43712
43710
  source: 'name',
@@ -43715,7 +43713,6 @@ export default defineType({
43715
43713
  },
43716
43714
  {
43717
43715
  name: 'image',
43718
- title: 'Image',
43719
43716
  type: 'image',
43720
43717
  options: {
43721
43718
  hotspot: true,
@@ -43730,11 +43727,9 @@ export default defineType({
43730
43727
  },
43731
43728
  {
43732
43729
  name: 'bio',
43733
- title: 'Bio',
43734
43730
  type: 'array',
43735
43731
  of: [
43736
43732
  {
43737
- title: 'Block',
43738
43733
  type: 'block',
43739
43734
  styles: [{title: 'Normal', value: 'normal'}],
43740
43735
  lists: [],
@@ -43750,6 +43745,7 @@ export default defineType({
43750
43745
  },
43751
43746
  }
43752
43747
  `, blockContentTS = `import {defineType, defineArrayMember} from 'sanity'
43748
+ import {ImageIcon} from '@sanity/icons'
43753
43749
 
43754
43750
  /**
43755
43751
  * This is the schema type for block content used in the post document type
@@ -43762,13 +43758,12 @@ export default defineType({
43762
43758
  * }
43763
43759
  */
43764
43760
 
43765
- export default defineType({
43761
+ export const blockContentType = defineType({
43766
43762
  title: 'Block Content',
43767
43763
  name: 'blockContent',
43768
43764
  type: 'array',
43769
43765
  of: [
43770
43766
  defineArrayMember({
43771
- title: 'Block',
43772
43767
  type: 'block',
43773
43768
  // Styles let you define what blocks can be marked up as. The default
43774
43769
  // set corresponds with HTML tags, but you can set any title or value
@@ -43813,6 +43808,7 @@ export default defineType({
43813
43808
  // as a block type.
43814
43809
  defineArrayMember({
43815
43810
  type: 'image',
43811
+ icon: ImageIcon,
43816
43812
  options: {hotspot: true},
43817
43813
  fields: [
43818
43814
  {
@@ -43824,7 +43820,9 @@ export default defineType({
43824
43820
  }),
43825
43821
  ],
43826
43822
  })
43827
- `, blockContentJS = `/**
43823
+ `, blockContentJS = `import {ImageIcon} from '@sanity/icons'
43824
+
43825
+ /**
43828
43826
  * This is the schema type for block content used in the post document type
43829
43827
  * Importing this type into the studio configuration's \`schema\` property
43830
43828
  * lets you reuse it in other document types with:
@@ -43835,7 +43833,7 @@ export default defineType({
43835
43833
  * }
43836
43834
  */
43837
43835
 
43838
- export const blockContent = {
43836
+ export const blockContentType = {
43839
43837
  title: 'Block Content',
43840
43838
  name: 'blockContent',
43841
43839
  type: 'array',
@@ -43886,6 +43884,7 @@ export const blockContent = {
43886
43884
  // as a block type.
43887
43885
  {
43888
43886
  type: 'image',
43887
+ icon: ImageIcon,
43889
43888
  options: {hotspot: true},
43890
43889
  fields: [
43891
43890
  {
@@ -43899,55 +43898,48 @@ export const blockContent = {
43899
43898
  }
43900
43899
  `, categoryTS = `import {defineField, defineType} from 'sanity'
43901
43900
 
43902
- export default defineType({
43901
+ export const categoryType = defineType({
43903
43902
  name: 'category',
43904
- title: 'Category',
43905
43903
  type: 'document',
43906
43904
  fields: [
43907
43905
  defineField({
43908
43906
  name: 'title',
43909
- title: 'Title',
43910
43907
  type: 'string',
43911
43908
  }),
43912
43909
  defineField({
43913
43910
  name: 'description',
43914
- title: 'Description',
43915
43911
  type: 'text',
43916
43912
  }),
43917
43913
  ],
43918
43914
  })
43919
- `, categoryJS = `export const category = {
43915
+ `, categoryJS = `export const categoryType = {
43920
43916
  name: 'category',
43921
43917
  title: 'Category',
43922
43918
  type: 'document',
43923
43919
  fields: [
43924
43920
  {
43925
43921
  name: 'title',
43926
- title: 'Title',
43927
43922
  type: 'string',
43928
43923
  },
43929
43924
  {
43930
43925
  name: 'description',
43931
- title: 'Description',
43932
43926
  type: 'text',
43933
43927
  },
43934
43928
  ],
43935
43929
  }
43936
43930
  `, postTS = `import {defineField, defineType} from 'sanity'
43937
43931
 
43938
- export default defineType({
43932
+ export const postType = defineType({
43939
43933
  name: 'post',
43940
43934
  title: 'Post',
43941
43935
  type: 'document',
43942
43936
  fields: [
43943
43937
  defineField({
43944
43938
  name: 'title',
43945
- title: 'Title',
43946
43939
  type: 'string',
43947
43940
  }),
43948
43941
  defineField({
43949
43942
  name: 'slug',
43950
- title: 'Slug',
43951
43943
  type: 'slug',
43952
43944
  options: {
43953
43945
  source: 'title',
@@ -43956,13 +43948,11 @@ export default defineType({
43956
43948
  }),
43957
43949
  defineField({
43958
43950
  name: 'author',
43959
- title: 'Author',
43960
43951
  type: 'reference',
43961
43952
  to: {type: 'author'},
43962
43953
  }),
43963
43954
  defineField({
43964
43955
  name: 'mainImage',
43965
- title: 'Main image',
43966
43956
  type: 'image',
43967
43957
  options: {
43968
43958
  hotspot: true,
@@ -43971,28 +43961,24 @@ export default defineType({
43971
43961
  {
43972
43962
  name: 'alt',
43973
43963
  type: 'string',
43974
- title: 'Alternative Text',
43964
+ title: 'Alternative text',
43975
43965
  }
43976
43966
  ]
43977
43967
  }),
43978
43968
  defineField({
43979
43969
  name: 'categories',
43980
- title: 'Categories',
43981
43970
  type: 'array',
43982
43971
  of: [{type: 'reference', to: {type: 'category'}}],
43983
43972
  }),
43984
43973
  defineField({
43985
43974
  name: 'publishedAt',
43986
- title: 'Published at',
43987
43975
  type: 'datetime',
43988
43976
  }),
43989
43977
  defineField({
43990
43978
  name: 'body',
43991
- title: 'Body',
43992
43979
  type: 'blockContent',
43993
43980
  }),
43994
43981
  ],
43995
-
43996
43982
  preview: {
43997
43983
  select: {
43998
43984
  title: 'title',
@@ -44005,19 +43991,17 @@ export default defineType({
44005
43991
  },
44006
43992
  },
44007
43993
  })
44008
- `, postJS = `export const post = {
43994
+ `, postJS = `export const postType = {
44009
43995
  name: 'post',
44010
43996
  title: 'Post',
44011
43997
  type: 'document',
44012
43998
  fields: [
44013
43999
  {
44014
44000
  name: 'title',
44015
- title: 'Title',
44016
44001
  type: 'string',
44017
44002
  },
44018
44003
  {
44019
44004
  name: 'slug',
44020
- title: 'Slug',
44021
44005
  type: 'slug',
44022
44006
  options: {
44023
44007
  source: 'title',
@@ -44026,13 +44010,11 @@ export default defineType({
44026
44010
  },
44027
44011
  {
44028
44012
  name: 'author',
44029
- title: 'Author',
44030
44013
  type: 'reference',
44031
44014
  to: {type: 'author'},
44032
44015
  },
44033
44016
  {
44034
44017
  name: 'mainImage',
44035
- title: 'Main image',
44036
44018
  type: 'image',
44037
44019
  options: {
44038
44020
  hotspot: true,
@@ -44041,28 +44023,24 @@ export default defineType({
44041
44023
  {
44042
44024
  name: 'alt',
44043
44025
  type: 'string',
44044
- title: 'Alternative Text',
44026
+ title: 'Alternative text',
44045
44027
  }
44046
44028
  ]
44047
44029
  },
44048
44030
  {
44049
44031
  name: 'categories',
44050
- title: 'Categories',
44051
44032
  type: 'array',
44052
44033
  of: [{type: 'reference', to: {type: 'category'}}],
44053
44034
  },
44054
44035
  {
44055
44036
  name: 'publishedAt',
44056
- title: 'Published at',
44057
44037
  type: 'datetime',
44058
44038
  },
44059
44039
  {
44060
44040
  name: 'body',
44061
- title: 'Body',
44062
44041
  type: 'blockContent',
44063
44042
  },
44064
44043
  ],
44065
-
44066
44044
  preview: {
44067
44045
  select: {
44068
44046
  title: 'title',
@@ -44077,28 +44055,28 @@ export default defineType({
44077
44055
  }
44078
44056
  `, blogSchemaTS = `import { type SchemaTypeDefinition } from 'sanity'
44079
44057
 
44080
- import blockContent from './schemaTypes/blockContent'
44081
- import category from './schemaTypes/category'
44082
- import post from './schemaTypes/post'
44083
- import author from './schemaTypes/author'
44058
+ import {blockContentType} from './schemaTypes/blockContentType'
44059
+ import {categoryType} from './schemaTypes/categoryType'
44060
+ import {postType} from './schemaTypes/postType'
44061
+ import {authorType} from './schemaTypes/authorType'
44084
44062
 
44085
44063
  export const schema: { types: SchemaTypeDefinition[] } = {
44086
- types: [post, author, category, blockContent],
44064
+ types: [blockContentType, categoryType, postType, authorType],
44087
44065
  }
44088
- `, blogSchemaJS = `import {blockContent} from './schemaTypes/blockContent'
44089
- import {category} from './schemaTypes/category'
44090
- import {post} from './schemaTypes/post'
44091
- import {author} from './schemaTypes/author'
44066
+ `, blogSchemaJS = `import {blockContentType} from './schemaTypes/blockContentType'
44067
+ import {categoryType} from './schemaTypes/categoryType'
44068
+ import {postType} from './schemaTypes/postType'
44069
+ import {authorType} from './schemaTypes/authorType'
44092
44070
 
44093
44071
  export const schema = {
44094
- types: [post, author, category, blockContent],
44072
+ types: [blockContentType, categoryType, postType, authorType],
44095
44073
  }
44096
44074
  `, blogSchemaFolder = (useTypeScript) => ({
44097
- "author.": useTypeScript ? authorTS : authorJS,
44098
- "blockContent.": useTypeScript ? blockContentTS : blockContentJS,
44099
- "category.": useTypeScript ? categoryTS : categoryJS,
44100
- "post.": useTypeScript ? postTS : postJS
44101
- }), sanityConfigTemplate = `'use client'
44075
+ "authorType.": useTypeScript ? authorTS : authorJS,
44076
+ "blockContentType.": useTypeScript ? blockContentTS : blockContentJS,
44077
+ "categoryType.": useTypeScript ? categoryTS : categoryJS,
44078
+ "postType.": useTypeScript ? postTS : postJS
44079
+ }), sanityConfigTemplate = (hasSrcFolder = !1) => `'use client'
44102
44080
 
44103
44081
  /**
44104
44082
  * This configuration is used to for the Sanity Studio that\u2019s mounted on the \`:route:\` route
@@ -44109,8 +44087,8 @@ import {defineConfig} from 'sanity'
44109
44087
  import {structureTool} from 'sanity/structure'
44110
44088
 
44111
44089
  // Go to https://www.sanity.io/docs/api-versioning to learn how API versioning works
44112
- import {apiVersion, dataset, projectId} from './sanity/env'
44113
- import {schema} from './sanity/schema'
44090
+ import {apiVersion, dataset, projectId} from ${hasSrcFolder ? "'./src/sanity/env'" : "'./sanity/env'"}
44091
+ import {schema} from ${hasSrcFolder ? "'./src/sanity/schema'" : "'./sanity/schema'"}
44114
44092
 
44115
44093
  export default defineConfig({
44116
44094
  basePath: ':basePath:',
@@ -44166,8 +44144,6 @@ export const projectId = assertValue(
44166
44144
  'Missing environment variable: NEXT_PUBLIC_SANITY_PROJECT_ID'
44167
44145
  )
44168
44146
 
44169
- export const useCdn = false
44170
-
44171
44147
  function assertValue<T>(v: T | undefined, errorMessage: string): T {
44172
44148
  if (v === undefined) {
44173
44149
  throw new Error(errorMessage)
@@ -44180,7 +44156,6 @@ function assertValue<T>(v: T | undefined, errorMessage: string): T {
44180
44156
 
44181
44157
  export const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET;
44182
44158
  export const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID;
44183
- export const useCdn = false
44184
44159
  `, schemaTS = `import { type SchemaTypeDefinition } from 'sanity'
44185
44160
 
44186
44161
  export const schema: { types: SchemaTypeDefinition[] } = {
@@ -44191,39 +44166,34 @@ export const schema: { types: SchemaTypeDefinition[] } = {
44191
44166
  }
44192
44167
  `, client = `import { createClient } from 'next-sanity'
44193
44168
 
44194
- import { apiVersion, dataset, projectId, useCdn } from '../env'
44169
+ import { apiVersion, dataset, projectId } from '../env'
44195
44170
 
44196
44171
  export const client = createClient({
44197
44172
  projectId,
44198
44173
  dataset,
44199
44174
  apiVersion,
44200
- useCdn,
44201
- perspective: 'published',
44175
+ useCdn: true, // Set to false if statically generating pages, using ISR or tag-based revalidation
44202
44176
  })
44203
44177
  `, imageTS = `import createImageUrlBuilder from '@sanity/image-url'
44204
- import type { Image } from 'sanity'
44178
+ import { SanityImageSource } from "@sanity/image-url/lib/types/types";
44205
44179
 
44206
44180
  import { dataset, projectId } from '../env'
44207
44181
 
44208
- const imageBuilder = createImageUrlBuilder({
44209
- projectId: projectId || '',
44210
- dataset: dataset || '',
44211
- })
44182
+ // https://www.sanity.io/docs/image-url
44183
+ const builder = createImageUrlBuilder({ projectId, dataset })
44212
44184
 
44213
- export const urlForImage = (source: Image) => {
44214
- return imageBuilder?.image(source).auto('format').fit('max').url()
44185
+ export const urlFor = (source: SanityImageSource) => {
44186
+ return builder.image(source)
44215
44187
  }
44216
44188
  `, imageJS = `import createImageUrlBuilder from '@sanity/image-url'
44217
44189
 
44218
44190
  import { dataset, projectId } from '../env'
44219
44191
 
44220
- const imageBuilder = createImageUrlBuilder({
44221
- projectId: projectId || '',
44222
- dataset: dataset || '',
44223
- })
44192
+ // https://www.sanity.io/docs/image-url
44193
+ const builder = createImageUrlBuilder({ projectId, dataset })
44224
44194
 
44225
- export const urlForImage = (source) => {
44226
- return imageBuilder?.image(source).auto('format').fit('max').url()
44195
+ export const urlFor = (source) => {
44196
+ return builder.image(source)
44227
44197
  }
44228
44198
  `, sanityFolder = (useTypeScript, template) => {
44229
44199
  const isBlogTemplate = template === "blog", structure = {
@@ -44363,11 +44333,12 @@ You can find your project on Sanity Manage \u2014 https://www.sanity.io/manage/p
44363
44333
  if (outputPath = answers.outputPath, initNext) {
44364
44334
  const useTypeScript2 = unattended ? !0 : await promptForTypeScript(prompt2);
44365
44335
  trace.log({ step: "useTypeScript", selectedOption: useTypeScript2 ? "yes" : "no" });
44366
- const fileExtension = useTypeScript2 ? "ts" : "js";
44367
- if (unattended || await promptForEmbeddedStudio(prompt2)) {
44368
- const srcDir = "app";
44369
- let srcPath = path__default.default.join(workDir, srcDir);
44370
- fs$p.existsSync(srcPath) || (srcPath = path__default.default.join(workDir, "src", srcDir), fs$p.existsSync(srcPath) || await fs__default$1.default.mkdir(srcPath, { recursive: !0 }).catch(() => loadEnv.debug("Error creating folder %s", srcPath)));
44336
+ const fileExtension = useTypeScript2 ? "ts" : "js", embeddedStudio = unattended ? !0 : await promptForEmbeddedStudio(prompt2);
44337
+ let hasSrcFolder = !1;
44338
+ if (embeddedStudio) {
44339
+ const appDir = "app";
44340
+ let srcPath = path__default.default.join(workDir, appDir);
44341
+ fs$p.existsSync(srcPath) || (srcPath = path__default.default.join(workDir, "src", appDir), hasSrcFolder = !0, fs$p.existsSync(srcPath) || await fs__default$1.default.mkdir(srcPath, { recursive: !0 }).catch(() => loadEnv.debug("Error creating folder %s", srcPath)));
44371
44342
  const studioPath = unattended ? "/studio" : await promptForStudioPath(prompt2), embeddedStudioRouteFilePath = path__default.default.join(
44372
44343
  srcPath,
44373
44344
  `${studioPath}/`,
@@ -44383,19 +44354,27 @@ You can find your project on Sanity Manage \u2014 https://www.sanity.io/manage/p
44383
44354
  const sanityConfigPath = path__default.default.join(workDir, `sanity.config.${fileExtension}`);
44384
44355
  await writeOrOverwrite(
44385
44356
  sanityConfigPath,
44386
- sanityConfigTemplate.replace(":route:", embeddedStudioRouteFilePath.slice(workDir.length).replace("src/", "")).replace(":basePath:", studioPath)
44357
+ sanityConfigTemplate(hasSrcFolder).replace(":route:", embeddedStudioRouteFilePath.slice(workDir.length).replace("src/", "")).replace(":basePath:", studioPath)
44387
44358
  );
44388
44359
  }
44389
44360
  const sanityCliPath = path__default.default.join(workDir, `sanity.cli.${fileExtension}`);
44390
44361
  await writeOrOverwrite(sanityCliPath, sanityCliTemplate);
44391
- const writeSourceFiles = async (files, folderPath) => {
44362
+ const writeSourceFiles = async (files, folderPath, srcFolderPrefix) => {
44392
44363
  for (const [filePath, content] of Object.entries(files))
44393
44364
  filePath.includes(".") && typeof content == "string" ? await writeOrOverwrite(
44394
- path__default.default.join(workDir, "sanity", folderPath || "", `${filePath}${fileExtension}`),
44365
+ path__default.default.join(
44366
+ workDir,
44367
+ srcFolderPrefix ? "src" : "",
44368
+ "sanity",
44369
+ folderPath || "",
44370
+ `${filePath}${fileExtension}`
44371
+ ),
44395
44372
  content
44396
- ) : (await fs__default$1.default.mkdir(path__default.default.join(workDir, "sanity", filePath), { recursive: !0 }), typeof content == "object" && await writeSourceFiles(content, filePath));
44373
+ ) : (await fs__default$1.default.mkdir(path__default.default.join(workDir, srcFolderPrefix ? "src" : "", "sanity", filePath), {
44374
+ recursive: !0
44375
+ }), typeof content == "object" && await writeSourceFiles(content, filePath, srcFolderPrefix));
44397
44376
  }, templateToUse = unattended ? "clean" : await promptForNextTemplate(prompt2);
44398
- await writeSourceFiles(sanityFolder(useTypeScript2, templateToUse));
44377
+ await writeSourceFiles(sanityFolder(useTypeScript2, templateToUse), void 0, hasSrcFolder);
44399
44378
  const tsConfigPath = path__default.default.join(workDir, "tsconfig.json");
44400
44379
  if (useTypeScript2 && fs$p.existsSync(tsConfigPath)) {
44401
44380
  const tsConfigFile = fs$p.readFileSync(tsConfigPath, "utf8"), config2 = silverFleece.evaluate(tsConfigFile);
@@ -44428,7 +44407,8 @@ You can find your project on Sanity Manage \u2014 https://www.sanity.io/manage/p
44428
44407
  chosen === "npm" ? await execa$1("npm", ["install", "next-sanity@9"], execOptions) : chosen === "yarn" ? await execa$1("npx", ["install-peerdeps", "--yarn", "next-sanity@9"], execOptions) : chosen === "pnpm" && await execa$1("pnpm", ["install", "next-sanity@9"], execOptions), print(
44429
44408
  `
44430
44409
  ${chalk2.green("Success!")} Your Sanity configuration files has been added to this project`
44431
- ), process.exit(0);
44410
+ );
44411
+ return;
44432
44412
  }
44433
44413
  function countNestedFolders(path2) {
44434
44414
  const separator2 = path2.includes("\\") ? "\\" : "/";