@sanity/cli 3.92.1-next.33.d62ed552cc → 3.92.1-next.34.408c5e3892

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.
@@ -3792,6 +3792,9 @@ Examples:
3792
3792
  # Add a Function with a specific type
3793
3793
  sanity blueprints add function --fn-type document-publish
3794
3794
 
3795
+ # Add a Function using an example
3796
+ sanity blueprints add function --example example-name
3797
+
3795
3798
  # Add a JavaScript Function
3796
3799
  sanity blueprints add function --js
3797
3800
 
@@ -3810,7 +3813,25 @@ Examples:
3810
3813
  signature: "<type> [--name <name>] [--fn-type <document-publish>] [--fn-lang <ts|js>] [--javascript]",
3811
3814
  description: "Add a Resource to a Blueprint",
3812
3815
  async action(args, context) {
3813
- const { output, apiClient } = context, flags = { ...defaultFlags$b, ...args.extOptions }, client2 = apiClient({
3816
+ const { output, apiClient } = context, { extOptions } = args;
3817
+ if (extOptions.example) {
3818
+ const foundConflict = [
3819
+ "name",
3820
+ "n",
3821
+ "fn-type",
3822
+ "fn-language",
3823
+ "lang",
3824
+ "javascript",
3825
+ "js",
3826
+ "fn-helpers",
3827
+ "helpers",
3828
+ "fn-installer",
3829
+ "installer"
3830
+ ].find((key2) => extOptions[key2]);
3831
+ if (foundConflict)
3832
+ throw new Error(`--example can't be used with --${foundConflict}`);
3833
+ }
3834
+ const flags = { ...defaultFlags$b, ...extOptions }, client2 = apiClient({
3814
3835
  requireUser: !0,
3815
3836
  requireProject: !1
3816
3837
  }), { token: token2 } = client2.config();
@@ -3832,6 +3853,7 @@ Examples:
3832
3853
  ...cmdConfig.value,
3833
3854
  args: { type: resourceType },
3834
3855
  flags: {
3856
+ example: flags.example,
3835
3857
  name: flags.n ?? flags.name,
3836
3858
  "fn-type": flags["fn-type"],
3837
3859
  language: flags.lang ?? flags["fn-language"],
@@ -4020,11 +4042,14 @@ Options
4020
4042
  --project-id <id> Project ID to use
4021
4043
 
4022
4044
  Examples:
4023
- # Create a new Blueprint manifest file in the current directory
4045
+ # Create a new Blueprint project in the current directory
4024
4046
  sanity blueprints init
4025
4047
 
4026
- # Create a new Blueprint manifest file in a specific directory
4048
+ # Create a new Blueprint project in a specific directory
4027
4049
  sanity blueprints init my-sanity-project --type json
4050
+
4051
+ # Create a new Blueprint project in a specific directory with an example
4052
+ sanity blueprints init --example example-name
4028
4053
  `, defaultFlags$6 = {
4029
4054
  //
4030
4055
  }, initBlueprintsCommand = {
@@ -4039,7 +4064,21 @@ Examples:
4039
4064
  requireProject: !1
4040
4065
  }), { token: token2 } = client2.config();
4041
4066
  if (!token2) throw new Error("No API token found. Please run `sanity login`.");
4042
- const { blueprintInitCore } = await import("@sanity/runtime-cli/cores/blueprints"), { success, error: error2 } = await blueprintInitCore({
4067
+ const { blueprintInitCore } = await import("@sanity/runtime-cli/cores/blueprints");
4068
+ if (flags.example) {
4069
+ const foundConflict = [
4070
+ "blueprint-type",
4071
+ "type",
4072
+ "stack-id",
4073
+ "stackId",
4074
+ "stack",
4075
+ "stack-name",
4076
+ "name"
4077
+ ].find((key2) => flags[key2]);
4078
+ if (foundConflict)
4079
+ throw new Error(`--example can't be used with --${foundConflict}`);
4080
+ }
4081
+ const { success, error: error2 } = await blueprintInitCore({
4043
4082
  bin: "sanity",
4044
4083
  log: (message) => output.print(message),
4045
4084
  token: token2,
@@ -4047,6 +4086,7 @@ Examples:
4047
4086
  dir: dir ?? flags.dir
4048
4087
  },
4049
4088
  flags: {
4089
+ example: flags.example,
4050
4090
  "blueprint-type": flags["blueprint-type"] ?? flags.type,
4051
4091
  "project-id": flags["project-id"] ?? flags.projectId ?? flags.project,
4052
4092
  "stack-id": flags["stack-id"] ?? flags.stackId ?? flags.stack,
@@ -23522,23 +23562,23 @@ async function installDeclaredPackages(cwd, packageManager, context) {
23522
23562
  encoding: "utf8",
23523
23563
  env: getPartialEnvWithNpmPath(cwd),
23524
23564
  cwd,
23525
- stdio: "inherit"
23526
- }, npmArgs = ["install", "--legacy-peer-deps"];
23565
+ stdio: "pipe"
23566
+ };
23527
23567
  let result;
23528
- if (packageManager === "npm")
23529
- output.print(`Running 'npm ${npmArgs.join(" ")}'`), result = await execa("npm", npmArgs, execOptions);
23530
- else if (packageManager === "yarn") {
23531
- const yarnArgs = ["install"];
23532
- output.print(`Running 'yarn ${yarnArgs.join(" ")}'`), result = await execa("yarn", yarnArgs, execOptions);
23533
- } else if (packageManager === "pnpm") {
23534
- const pnpmArgs = ["install"];
23535
- output.print(`Running 'pnpm ${pnpmArgs.join(" ")}'`), result = await execa("pnpm", pnpmArgs, execOptions);
23536
- } else if (packageManager === "bun") {
23537
- const bunArgs = ["install"];
23538
- output.print(`Running 'bun ${bunArgs.join(" ")}'`), result = await execa("bun", bunArgs, execOptions);
23539
- } else packageManager === "manual" && output.print(`Manual installation selected - run 'npm ${npmArgs.join(" ")}' or similar`);
23540
- if (result?.exitCode || result?.failed)
23541
- throw new Error("Dependency installation failed");
23568
+ const installerArgs = {
23569
+ npm: ["install", "--legacy-peer-deps"],
23570
+ yarn: ["install"],
23571
+ pnpm: ["install"],
23572
+ bun: ["install"]
23573
+ };
23574
+ async function handleInstall(cmd, args) {
23575
+ const progress = output.spinner(`Running ${cmd} ${args.join(" ")}
23576
+ `).start();
23577
+ if (result = await execa(cmd, args, execOptions), result?.exitCode || result?.failed)
23578
+ throw progress.fail(), output.print(result.stdout), new Error("Dependency installation failed");
23579
+ progress.succeed();
23580
+ }
23581
+ packageManager === "manual" ? output.print(`Manual installation selected \u2014 run 'npm ${installerArgs.npm} or equivalent'`) : await handleInstall(packageManager, installerArgs[packageManager]);
23542
23582
  }
23543
23583
  async function installNewPackages(options2, context) {
23544
23584
  const { packageManager, packages } = options2, { output, workDir } = context, execOptions = {
@@ -53696,18 +53736,15 @@ ${chalk2.green("Success!")} Your Sanity configuration files has been added to th
53696
53736
  pnpm: "pnpm dev",
53697
53737
  bun: "bun dev",
53698
53738
  manual: "npm run dev"
53699
- }[pkgManager];
53700
- outputPath === process.cwd() ? (print(`
53701
- ${chalk2.green("Success!")} Now, use this command to continue:
53702
- `), print(
53703
- `${chalk2.cyan(devCommand)} - to run ${isAppTemplate ? "your Sanity application" : "Sanity Studio"}
53704
- `
53705
- )) : (print(`
53706
- ${chalk2.green("Success!")} Now, use these commands to continue:
53707
- `), print(`First: ${chalk2.cyan(`cd ${outputPath}`)} - to enter project's directory`), print(
53708
- `Then: ${chalk2.cyan(devCommand)} -to run ${isAppTemplate ? "your Sanity application" : "Sanity Studio"}
53709
- `
53710
- )), 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"), isFirstProject && (trace.log({ step: "sendCommunityInvite", selectedOption: "yes" }), print(`
53739
+ }[pkgManager], isCurrentDir = outputPath === process.cwd(), goToProjectDir = `(${chalk2.cyan(`cd ${outputPath}`)} to navigate to your new project directory)`;
53740
+ isAppTemplate ? (print(`\u2705 ${chalk2.green.bold("Success!")} Your custom app has been scaffolded.`), isCurrentDir || print(goToProjectDir), print(
53741
+ `
53742
+ ${chalk2.bold("Next")}, configure the project(s) and dataset(s) your app should work with.`
53743
+ ), print("\nGet started in `src/App.tsx`, or refer to our documentation for a walkthrough:"), print(chalk2.blue.underline("https://www.sanity.io/docs/app-sdk/sdk-configuration")), print(`
53744
+ `), print("Other helpful commands:"), print("npx sanity docs to open the documentation in a browser"), print("npx sanity dev to start the development server for your app"), print("npx sanity deploy to deploy your app")) : (print(`\u2705 ${chalk2.green.bold("Success!")} Your Studio has been created.`), isCurrentDir || print(goToProjectDir), print(
53745
+ `Get started by running ${chalk2.cyan(devCommand)} to launch your Studio\u2019s development server`
53746
+ ), print(`
53747
+ `), 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")), isFirstProject && (trace.log({ step: "sendCommunityInvite", selectedOption: "yes" }), print(`
53711
53748
  Join our wonderful developer community as well: ${chalk2.cyan("https://snty.link/community")}`), print(`We look forward to seeing you there!
53712
53749
  `)), trace.complete();
53713
53750
  async function getOrCreateUser() {
@@ -79649,7 +79686,10 @@ async function runCli(cliRoot, { cliVersion }) {
79649
79686
  await flushTelemetry();
79650
79687
  const error2 = typeof err.details == "string" ? err.details : err;
79651
79688
  console.error(`
79652
- ${error2.stack ? neatStack(err) : error2}`), cliCommandTrace.error(error2), process.exit(1);
79689
+ ${error2.stack ? neatStack(err) : error2}`), err.cause && console.error(`
79690
+ Caused by:
79691
+
79692
+ ${err.cause.stack ? neatStack(err.cause) : err.cause}`), cliCommandTrace.error(error2), process.exit(1);
79653
79693
  });
79654
79694
  }
79655
79695
  async function getCoreModulePath(workDir, cliConfig) {