@sanity/cli 3.72.2-canary.32 → 3.72.2-corel.23

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.
@@ -46514,38 +46514,6 @@ var typescriptExports = requireTypescript(), typescript = /* @__PURE__ */ loadEn
46514
46514
  __proto__: null,
46515
46515
  default: typescript
46516
46516
  }, [typescriptExports]);
46517
- function processTemplate(options2) {
46518
- const { template, variables, includeBooleanTransform = !1 } = options2, ast = mainExports.parse(template.trimStart(), { parser });
46519
- return traverse__default.default(ast, {
46520
- StringLiteral: {
46521
- enter({ node }) {
46522
- const value = node.value;
46523
- if (!value.startsWith("%") || !value.endsWith("%"))
46524
- return;
46525
- const variableName = value.slice(1, -1);
46526
- if (!(variableName in variables))
46527
- throw new Error(`Template variable '${value}' not defined`);
46528
- const newValue = variables[variableName];
46529
- node.value = typeof newValue == "string" ? newValue : "";
46530
- }
46531
- },
46532
- ...includeBooleanTransform && {
46533
- Identifier: {
46534
- enter(path2) {
46535
- if (!path2.node.name.startsWith("__BOOL__"))
46536
- return;
46537
- const variableName = path2.node.name.replace(/^__BOOL__(.+?)__$/, "$1");
46538
- if (!(variableName in variables))
46539
- throw new Error(`Template variable '${variableName.toString()}' not defined`);
46540
- const value = variables[variableName];
46541
- if (typeof value != "boolean")
46542
- throw new Error(`Expected boolean value for '${variableName.toString()}'`);
46543
- path2.replaceWith({ type: "BooleanLiteral", value });
46544
- }
46545
- }
46546
- }
46547
- }), mainExports.print(ast, { quote: "single" }).code;
46548
- }
46549
46517
  const defaultTemplate$1 = `
46550
46518
  import {defineCliConfig} from 'sanity/cli'
46551
46519
 
@@ -46562,26 +46530,37 @@ export default defineCliConfig({
46562
46530
  })
46563
46531
  `;
46564
46532
  function createCliConfig(options2) {
46565
- return processTemplate({
46566
- template: defaultTemplate$1,
46567
- variables: options2,
46568
- includeBooleanTransform: !0
46569
- });
46570
- }
46571
- const defaultCoreAppTemplate = `
46572
- import {defineCliConfig} from 'sanity/cli'
46573
-
46574
- export default defineCliConfig({
46575
- __experimental_coreAppConfiguration: {
46576
- appLocation: '%appLocation%'
46577
- },
46578
- })
46579
- `;
46580
- function createCoreAppCliConfig(options2) {
46581
- return processTemplate({
46582
- template: defaultCoreAppTemplate,
46583
- variables: options2
46584
- });
46533
+ const variables = options2, template = defaultTemplate$1.trimStart(), ast = mainExports.parse(template, { parser });
46534
+ return traverse__default.default(ast, {
46535
+ StringLiteral: {
46536
+ enter({ node }) {
46537
+ const value = node.value;
46538
+ if (!value.startsWith("%") || !value.endsWith("%"))
46539
+ return;
46540
+ const variableName = value.slice(1, -1);
46541
+ if (!(variableName in variables))
46542
+ throw new Error(`Template variable '${value}' not defined`);
46543
+ const newValue = variables[variableName];
46544
+ node.value = typeof newValue == "string" ? newValue : "";
46545
+ }
46546
+ },
46547
+ Identifier: {
46548
+ enter(path2) {
46549
+ if (!path2.node.name.startsWith("__BOOL__"))
46550
+ return;
46551
+ const variableName = path2.node.name.replace(
46552
+ /^__BOOL__(.+?)__$/,
46553
+ "$1"
46554
+ );
46555
+ if (!(variableName in variables))
46556
+ throw new Error(`Template variable '${variableName}' not defined`);
46557
+ const value = variables[variableName];
46558
+ if (typeof value != "boolean")
46559
+ throw new Error(`Expected boolean value for '${variableName}'`);
46560
+ path2.replaceWith({ type: "BooleanLiteral", value });
46561
+ }
46562
+ }
46563
+ }), mainExports.print(ast, { quote: "single" }).code;
46585
46564
  }
46586
46565
  /*!
46587
46566
  * isobject <https://github.com/jonschlinkert/isobject>
@@ -46651,7 +46630,7 @@ function createPackageManifest(data) {
46651
46630
  ...getCommonManifest(data),
46652
46631
  main: "package.json",
46653
46632
  keywords: ["sanity"],
46654
- scripts: data.scripts || {
46633
+ scripts: {
46655
46634
  dev: "sanity dev",
46656
46635
  start: "sanity start",
46657
46636
  build: "sanity build",
@@ -46720,42 +46699,25 @@ export default defineConfig({
46720
46699
  };
46721
46700
  function createStudioConfig(options2) {
46722
46701
  const variables = { ...defaultVariables, ...options2.variables };
46723
- return typeof options2.template == "function" ? options2.template(variables).trimStart() : processTemplate({
46724
- template: options2.template || defaultTemplate,
46725
- variables
46726
- });
46727
- }
46728
- const coreAppTemplates = ["core-app"];
46729
- function determineCoreAppTemplate(templateName) {
46730
- return coreAppTemplates.includes(templateName);
46702
+ if (typeof options2.template == "function")
46703
+ return options2.template(variables).trimStart();
46704
+ const template = (options2.template || defaultTemplate).trimStart(), ast = mainExports.parse(template, { parser });
46705
+ return traverse__default.default(ast, {
46706
+ StringLiteral: {
46707
+ enter({ node }) {
46708
+ const value = node.value;
46709
+ if (!value.startsWith("%") || !value.endsWith("%"))
46710
+ return;
46711
+ const variableName = value.slice(1, -1);
46712
+ if (!(variableName in variables))
46713
+ throw new Error(`Template variable '${value}' not defined`);
46714
+ const newValue = variables[variableName];
46715
+ node.value = typeof newValue == "string" ? newValue : "";
46716
+ }
46717
+ }
46718
+ }), mainExports.print(ast, { quote: "single" }).code;
46731
46719
  }
46732
- const blogTemplate = {}, cleanTemplate = {}, coreAppTemplate = {
46733
- dependencies: {
46734
- "@sanity/sdk": "^0.0.0-alpha",
46735
- "@sanity/sdk-react": "^0.0.0-alpha",
46736
- react: "^19",
46737
- "react-dom": "^19"
46738
- },
46739
- devDependencies: {
46740
- /*
46741
- * this will be changed to eslint-config sanity,
46742
- * eslint.config generation will be a fast follow
46743
- */
46744
- "@sanity/eslint-config-studio": "^5.0.1",
46745
- "@types/react": "^18.0.25",
46746
- eslint: "^9.9.0",
46747
- prettier: "^3.0.2",
46748
- sanity: "^3",
46749
- typescript: "^5.1.6"
46750
- },
46751
- appLocation: "./src/App.tsx",
46752
- scripts: {
46753
- // this will eventually run a concurrently process with another in-flight utility
46754
- dev: "sanity app dev",
46755
- build: "sanity app build",
46756
- start: "sanity app start"
46757
- }
46758
- }, configTemplate$3 = `
46720
+ const blogTemplate = {}, cleanTemplate = {}, configTemplate$3 = `
46759
46721
  import {defineConfig, isDev} from 'sanity'
46760
46722
  import {visionTool} from '@sanity/vision'
46761
46723
  import {structureTool} from 'sanity/structure'
@@ -46933,7 +46895,6 @@ export default defineConfig({
46933
46895
  }, templates = {
46934
46896
  blog: blogTemplate,
46935
46897
  clean: cleanTemplate,
46936
- "core-app": coreAppTemplate,
46937
46898
  "get-started": getStartedTemplate,
46938
46899
  moviedb: movieTemplate,
46939
46900
  shopify: shopifyTemplate$1,
@@ -46954,7 +46915,7 @@ async function updateInitialTemplateMetadata(apiClient, projectId, templateName)
46954
46915
  }
46955
46916
  }
46956
46917
  async function bootstrapLocalTemplate(opts, context) {
46957
- const { apiClient, cliRoot, output } = context, templatesDir = path__default.default.join(cliRoot, "templates"), { outputPath, templateName, useTypeScript, packageName, variables } = opts, sourceDir = path__default.default.join(templatesDir, templateName), sharedDir = path__default.default.join(templatesDir, "shared"), isCoreAppTemplate = determineCoreAppTemplate(templateName), template = templates[templateName];
46918
+ const { apiClient, cliRoot, output } = context, templatesDir = path__default.default.join(cliRoot, "templates"), { outputPath, templateName, useTypeScript, packageName, variables } = opts, sourceDir = path__default.default.join(templatesDir, templateName), sharedDir = path__default.default.join(templatesDir, "shared"), template = templates[templateName];
46958
46919
  if (!template)
46959
46920
  throw new Error(`Template "${templateName}" not defined`);
46960
46921
  loadEnv.debug('Copying files from template "%s" to "%s"', templateName, outputPath);
@@ -46969,20 +46930,19 @@ async function bootstrapLocalTemplate(opts, context) {
46969
46930
  schemaUrl: opts.schemaUrl
46970
46931
  })), spinner.succeed(), spinner = output.spinner("Resolving latest module versions").start();
46971
46932
  const dependencyVersions = await resolveLatestVersions({
46972
- ...isCoreAppTemplate ? {} : studioDependencies.dependencies,
46973
- ...isCoreAppTemplate ? {} : studioDependencies.devDependencies,
46974
- ...template.dependencies || {},
46975
- ...template.devDependencies || {}
46933
+ ...studioDependencies.dependencies,
46934
+ ...studioDependencies.devDependencies,
46935
+ ...template.dependencies || {}
46976
46936
  });
46977
46937
  spinner.succeed();
46978
46938
  const dependencies = Object.keys({
46979
- ...isCoreAppTemplate ? {} : studioDependencies.dependencies,
46939
+ ...studioDependencies.dependencies,
46980
46940
  ...template.dependencies
46981
46941
  }).reduce(
46982
46942
  (deps, dependency) => (deps[dependency] = dependencyVersions[dependency], deps),
46983
46943
  {}
46984
46944
  ), devDependencies = Object.keys({
46985
- ...isCoreAppTemplate ? {} : studioDependencies.devDependencies,
46945
+ ...studioDependencies.devDependencies,
46986
46946
  ...template.devDependencies
46987
46947
  }).reduce(
46988
46948
  (deps, dependency) => (deps[dependency] = dependencyVersions[dependency], deps),
@@ -46992,30 +46952,27 @@ async function bootstrapLocalTemplate(opts, context) {
46992
46952
  const packageManifest = await createPackageManifest({
46993
46953
  name: packageName,
46994
46954
  dependencies,
46995
- devDependencies,
46996
- scripts: template.scripts
46997
- }), studioConfig = createStudioConfig({
46955
+ devDependencies
46956
+ }), studioConfig = await createStudioConfig({
46998
46957
  template: template.configTemplate,
46999
46958
  variables
47000
- }), cliConfig = isCoreAppTemplate ? createCoreAppCliConfig({ appLocation: template.appLocation }) : createCliConfig({
46959
+ }), cliConfig = await createCliConfig({
47001
46960
  projectId: variables.projectId,
47002
46961
  dataset: variables.dataset,
47003
46962
  autoUpdates: variables.autoUpdates
47004
46963
  }), codeExt = useTypeScript ? "ts" : "js";
47005
- return await Promise.all(
47006
- [
47007
- isCoreAppTemplate ? Promise.resolve(null) : writeFileIfNotExists(`sanity.config.${codeExt}`, studioConfig),
47008
- writeFileIfNotExists(`sanity.cli.${codeExt}`, cliConfig),
47009
- writeFileIfNotExists("package.json", packageManifest),
47010
- writeFileIfNotExists(
47011
- "eslint.config.mjs",
47012
- `import studio from '@sanity/eslint-config-studio'
46964
+ return await Promise.all([
46965
+ writeFileIfNotExists(`sanity.config.${codeExt}`, studioConfig),
46966
+ writeFileIfNotExists(`sanity.cli.${codeExt}`, cliConfig),
46967
+ writeFileIfNotExists("package.json", packageManifest),
46968
+ writeFileIfNotExists(
46969
+ "eslint.config.mjs",
46970
+ `import studio from '@sanity/eslint-config-studio'
47013
46971
 
47014
46972
  export default [...studio]
47015
46973
  `
47016
- )
47017
- ].filter(Boolean)
47018
- ), loadEnv.debug("Updating initial template metadata"), await updateInitialTemplateMetadata(apiClient, variables.projectId, `cli-${templateName}`), spinner.succeed(), template;
46974
+ )
46975
+ ]), loadEnv.debug("Updating initial template metadata"), await updateInitialTemplateMetadata(apiClient, variables.projectId, `cli-${templateName}`), spinner.succeed(), template;
47019
46976
  async function writeFileIfNotExists(fileName, content) {
47020
46977
  const filePath = path__default.default.join(outputPath, fileName);
47021
46978
  try {
@@ -52634,7 +52591,7 @@ ${err.message}`);
52634
52591
  } else unattended || (trace.log({ step: "login" }), await getOrCreateUser());
52635
52592
  let introMessage = "Fetching existing projects";
52636
52593
  cliFlags.quickstart && (introMessage = "Eject your existing project's Sanity configuration"), success(introMessage), print("");
52637
- const flags = await prepareFlags(), isCoreAppTemplate = cliFlags.template ? determineCoreAppTemplate(cliFlags.template) : !1, { projectId, displayName, isFirstProject, datasetName, schemaUrl } = await getProjectDetails(), sluggedName = lodashExports.deburr(displayName.toLowerCase()).replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
52594
+ const flags = await prepareFlags(), { projectId, displayName, isFirstProject, datasetName, schemaUrl } = await getProjectDetails(), sluggedName = lodashExports.deburr(displayName.toLowerCase()).replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
52638
52595
  if (bareOutput) {
52639
52596
  success("Below are your project details"), print(""), print(`Project ID: ${chalk2.cyan(projectId)}`), print(`Dataset: ${chalk2.cyan(datasetName)}`), print(
52640
52597
  `
@@ -52824,15 +52781,11 @@ ${chalk2.green("Success!")} Your Sanity configuration files has been added to th
52824
52781
  }[pkgManager];
52825
52782
  outputPath === process.cwd() ? (print(`
52826
52783
  ${chalk2.green("Success!")} Now, use this command to continue:
52827
- `), print(
52828
- `${chalk2.cyan(devCommand)} - to run ${isCoreAppTemplate ? "your Sanity application" : "Sanity Studio"}
52829
- `
52830
- )) : (print(`
52784
+ `), print(`${chalk2.cyan(devCommand)} - to run Sanity Studio
52785
+ `)) : (print(`
52831
52786
  ${chalk2.green("Success!")} Now, use these commands to continue:
52832
- `), print(`First: ${chalk2.cyan(`cd ${outputPath}`)} - to enter project\u2019s directory`), print(
52833
- `Then: ${chalk2.cyan(devCommand)} -to run ${isCoreAppTemplate ? "your Sanity application" : "Sanity Studio"}
52834
- `
52835
- )), print("Other helpful commands"), print("npx sanity docs - to open the documentation in a browser"), print("npx sanity manage - to open the project settings in a browser"), print("npx sanity help - to explore the CLI manual");
52787
+ `), print(`First: ${chalk2.cyan(`cd ${outputPath}`)} - to enter project\u2019s directory`), print(`Then: ${chalk2.cyan(devCommand)} - to run Sanity Studio
52788
+ `)), print("Other helpful commands"), print("npx sanity docs - to open the documentation in a browser"), print("npx sanity manage - to open the project settings in a browser"), print("npx sanity help - to explore the CLI manual");
52836
52789
  const sendInvite = isFirstProject && await prompt2.single({
52837
52790
  type: "confirm",
52838
52791
  message: "We have an excellent developer community, would you like us to send you an invitation to join?",
@@ -52859,13 +52812,6 @@ ${chalk2.green("Success!")} Now, use these commands to continue:
52859
52812
  isFirstProject: data.isFirstProject
52860
52813
  }), data;
52861
52814
  }
52862
- if (isCoreAppTemplate)
52863
- return {
52864
- projectId: "",
52865
- displayName: "",
52866
- isFirstProject: !1,
52867
- datasetName: ""
52868
- };
52869
52815
  loadEnv.debug("Prompting user to select or create a project");
52870
52816
  const project = await getOrCreateProject();
52871
52817
  loadEnv.debug(`Project with name ${project.displayName} selected`), loadEnv.debug("Prompting user to select or create a dataset");