@sanity/cli 6.5.0 → 6.5.1

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 (42) hide show
  1. package/README.md +190 -98
  2. package/dist/actions/build/buildApp.js +35 -14
  3. package/dist/actions/build/buildApp.js.map +1 -1
  4. package/dist/actions/build/buildStudio.js +54 -26
  5. package/dist/actions/build/buildStudio.js.map +1 -1
  6. package/dist/actions/build/buildVendorDependencies.js +3 -2
  7. package/dist/actions/build/buildVendorDependencies.js.map +1 -1
  8. package/dist/actions/build/checkRequiredDependencies.js +2 -5
  9. package/dist/actions/build/checkRequiredDependencies.js.map +1 -1
  10. package/dist/actions/build/checkStudioDependencyVersions.js +1 -2
  11. package/dist/actions/build/checkStudioDependencyVersions.js.map +1 -1
  12. package/dist/actions/build/getViteConfig.js +2 -1
  13. package/dist/actions/build/getViteConfig.js.map +1 -1
  14. package/dist/actions/codemods/reactIconsV3.js +1 -1
  15. package/dist/actions/codemods/reactIconsV3.js.map +1 -1
  16. package/dist/actions/deploy/deployApp.js +1 -1
  17. package/dist/actions/deploy/deployApp.js.map +1 -1
  18. package/dist/actions/deploy/deployStudio.js +1 -2
  19. package/dist/actions/deploy/deployStudio.js.map +1 -1
  20. package/dist/actions/dev/startStudioDevServer.js +1 -2
  21. package/dist/actions/dev/startStudioDevServer.js.map +1 -1
  22. package/dist/actions/manifest/extractAppManifest.js +3 -2
  23. package/dist/actions/manifest/extractAppManifest.js.map +1 -1
  24. package/dist/actions/manifest/types.js +9 -0
  25. package/dist/actions/manifest/types.js.map +1 -1
  26. package/dist/actions/manifest/writeManifestFile.js +1 -2
  27. package/dist/actions/manifest/writeManifestFile.js.map +1 -1
  28. package/dist/actions/schema/uploadSchemaToLexicon.js +1 -2
  29. package/dist/actions/schema/uploadSchemaToLexicon.js.map +1 -1
  30. package/dist/actions/versions/buildPackageArray.js +1 -1
  31. package/dist/actions/versions/buildPackageArray.js.map +1 -1
  32. package/dist/constants.js +8 -0
  33. package/dist/constants.js.map +1 -0
  34. package/dist/server/previewServer.js +1 -1
  35. package/dist/server/previewServer.js.map +1 -1
  36. package/dist/services/userApplications.js.map +1 -1
  37. package/dist/util/compareDependencyVersions.js +1 -2
  38. package/dist/util/compareDependencyVersions.js.map +1 -1
  39. package/oclif.manifest.json +1 -1
  40. package/package.json +9 -9
  41. package/dist/util/getLocalPackageVersion.js +0 -55
  42. package/dist/util/getLocalPackageVersion.js.map +0 -1
package/README.md CHANGED
@@ -24,7 +24,9 @@ Code for sanity cli
24
24
  - [`sanity blueprints info`](#sanity-blueprints-info)
25
25
  - [`sanity blueprints init [DIR]`](#sanity-blueprints-init-dir)
26
26
  - [`sanity blueprints logs`](#sanity-blueprints-logs)
27
+ - [`sanity blueprints mint-deploy-token`](#sanity-blueprints-mint-deploy-token)
27
28
  - [`sanity blueprints plan`](#sanity-blueprints-plan)
29
+ - [`sanity blueprints promote`](#sanity-blueprints-promote)
28
30
  - [`sanity blueprints stacks`](#sanity-blueprints-stacks)
29
31
  - [`sanity build [OUTPUTDIR]`](#sanity-build-outputdir)
30
32
  - [`sanity codemod [CODEMODNAME]`](#sanity-codemod-codemodname)
@@ -255,7 +257,7 @@ EXAMPLES
255
257
 
256
258
  ```
257
259
  USAGE
258
- $ sanity blueprints add TYPE [--json] [--validate-resources] [--example <value> | -n <value> | --fn-type
260
+ $ sanity blueprints add TYPE [--json] [--example <value> | -n <value> | --fn-type
259
261
  document-publish|document-create|document-delete|document-update|media-library-asset-create|media-library-asset-dele
260
262
  te|media-library-asset-update|scheduled-function|sync-tag-invalidate... | --language ts|js | --javascript |
261
263
  --fn-helpers | --fn-installer skip|npm|pnpm|yarn] [-i | ]
@@ -264,23 +266,22 @@ ARGUMENTS
264
266
  TYPE (function) Type of resource to add (only "function" is supported)
265
267
 
266
268
  FLAGS
267
- -i, --install Shortcut for --fn-installer npm
268
- -n, --name=<value> Name of the resource to add
269
- --example=<value> Example to use for the function resource. Discover examples at
270
- https://www.sanity.io/exchange/type=recipes/by=sanity
271
- --[no-]fn-helpers Add helpers to the new function
272
- --fn-installer=<option> Which package manager to use when installing the @sanity/functions helpers
273
- <options: skip|npm|pnpm|yarn>
274
- --fn-type=<option>... Document change event(s) that should trigger the function; you can specify multiple
275
- events by specifying this flag multiple times
276
- <options: document-publish|document-create|document-delete|document-update|media-librar
277
- y-asset-create|media-library-asset-delete|media-library-asset-update|scheduled-function
278
- |sync-tag-invalidate>
279
- --javascript Use JavaScript instead of TypeScript
280
- --json Format output as json
281
- --language=<option> [default: ts] Language of the new function
282
- <options: ts|js>
283
- --[no-]validate-resources Validate resources
269
+ -i, --install Shortcut for --fn-installer npm
270
+ -n, --name=<value> Name of the resource to add
271
+ --example=<value> Example to use for the function resource. Discover examples at
272
+ https://www.sanity.io/exchange/type=recipes/by=sanity
273
+ --[no-]fn-helpers Add helpers to the new function
274
+ --fn-installer=<option> Which package manager to use when installing the @sanity/functions helpers
275
+ <options: skip|npm|pnpm|yarn>
276
+ --fn-type=<option>... Document change event(s) that should trigger the function; you can specify multiple
277
+ events by specifying this flag multiple times
278
+ <options: document-publish|document-create|document-delete|document-update|media-library-
279
+ asset-create|media-library-asset-delete|media-library-asset-update|scheduled-function|syn
280
+ c-tag-invalidate>
281
+ --javascript Use JavaScript instead of TypeScript
282
+ --json Format output as json
283
+ --language=<option> [default: ts] Language of the new function
284
+ <options: ts|js>
284
285
 
285
286
  DESCRIPTION
286
287
  [deprecated] Use "functions add" instead
@@ -309,8 +310,7 @@ View or edit the local Blueprint configuration
309
310
 
310
311
  ```
311
312
  USAGE
312
- $ sanity blueprints config [--json] [--validate-resources] [--stack <value> -e] [--project-id <value> ]
313
- [--organization-id <value> ]
313
+ $ sanity blueprints config [--json] [--stack <value> -e] [--project-id <value> ] [--organization-id <value> ]
314
314
 
315
315
  FLAGS
316
316
  -e, --edit Modify the configuration interactively, or directly when combined with ID flags.
@@ -318,7 +318,6 @@ FLAGS
318
318
  --organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
319
319
  --project-id=<value> Sanity project ID used to scope Blueprint and Stack
320
320
  --stack=<value> Stack name or ID to set in the configuration. Requires --edit flag
321
- --[no-]validate-resources Validate resources
322
321
 
323
322
  DESCRIPTION
324
323
  View or edit the local Blueprint configuration
@@ -346,14 +345,17 @@ Deploy the local Blueprint to the remote Stack
346
345
 
347
346
  ```
348
347
  USAGE
349
- $ sanity blueprints deploy [--json] [--validate-resources] [--stack <value>] [-m <value>] [--no-wait]
348
+ $ sanity blueprints deploy [--json] [--stack <value>] [--project-id <value> | --organization-id <value>] [-m <value>]
349
+ [--no-wait] [--new-stack-name <value>]
350
350
 
351
351
  FLAGS
352
352
  -m, --message=<value> Message describing the deployment (e.g. reason for change)
353
353
  --json Format output as json
354
+ --new-stack-name=<value> Set a new name for the Stack
354
355
  --no-wait Do not wait for Stack deployment to complete
356
+ --organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
357
+ --project-id=<value> Sanity project ID used to scope Blueprint and Stack
355
358
  --stack=<value> Stack name or ID to use instead of the locally configured Stack
356
- --[no-]validate-resources Validate resources
357
359
 
358
360
  DESCRIPTION
359
361
  Deploy the local Blueprint to the remote Stack
@@ -378,6 +380,12 @@ EXAMPLES
378
380
  $ sanity blueprints deploy --no-wait
379
381
 
380
382
  $ sanity blueprints deploy --fn-installer npm
383
+
384
+ $ sanity blueprints deploy --stack <name-or-id>
385
+
386
+ $ sanity blueprints deploy --organization-id <orgId> --stack <name-or-id>
387
+
388
+ $ sanity blueprints deploy --new-stack-name <new-name>
381
389
  ```
382
390
 
383
391
  ## `sanity blueprints destroy`
@@ -386,8 +394,8 @@ Destroy a remote Stack deployment and its resources
386
394
 
387
395
  ```
388
396
  USAGE
389
- $ sanity blueprints destroy [--json] [--validate-resources] [--project-id <value> --stack <value> --force]
390
- [--organization-id <value> ] [--no-wait]
397
+ $ sanity blueprints destroy [--json] [--project-id <value> --stack <value> --force] [--organization-id <value> ]
398
+ [--no-wait]
391
399
 
392
400
  FLAGS
393
401
  --force Force Stack destruction (skip confirmation)
@@ -396,7 +404,6 @@ FLAGS
396
404
  --organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
397
405
  --project-id=<value> Sanity project ID used to scope Blueprint and Stack
398
406
  --stack=<value> Stack name or ID to destroy (defaults to the locally configured Stack)
399
- --[no-]validate-resources Validate resources
400
407
 
401
408
  DESCRIPTION
402
409
  Destroy a remote Stack deployment and its resources
@@ -420,14 +427,13 @@ Diagnose potential issues with local Blueprint and remote Stack configuration
420
427
 
421
428
  ```
422
429
  USAGE
423
- $ sanity blueprints doctor [--json] [-p <value>] [--validate-resources] [--verbose] [--fix]
430
+ $ sanity blueprints doctor [--json] [-p <value>] [--verbose] [--fix]
424
431
 
425
432
  FLAGS
426
- -p, --path=<value> [env: SANITY_BLUEPRINT_PATH] Path to a Blueprint file or directory containing one
427
- --fix Interactively fix configuration issues
428
- --json Format output as json
429
- --[no-]validate-resources Validate resources
430
- --[no-]verbose Verbose output; defaults to true
433
+ -p, --path=<value> [env: SANITY_BLUEPRINT_PATH] Path to a Blueprint file or directory containing one
434
+ --fix Interactively fix configuration issues
435
+ --json Format output as json
436
+ --[no-]verbose Verbose output; defaults to true
431
437
 
432
438
  DESCRIPTION
433
439
  Diagnose potential issues with local Blueprint and remote Stack configuration
@@ -450,13 +456,13 @@ Display the status and resources of the remote Stack deployment
450
456
 
451
457
  ```
452
458
  USAGE
453
- $ sanity blueprints info [--json] [--validate-resources] [--stack <value>] [--project-id <value>]
459
+ $ sanity blueprints info [--json] [--stack <value>] [--project-id <value> | --organization-id <value>]
454
460
 
455
461
  FLAGS
456
462
  --json Format output as json
463
+ --organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
457
464
  --project-id=<value> Sanity project ID used to scope Blueprint and Stack
458
465
  --stack=<value> Stack name or ID
459
- --[no-]validate-resources Validate resources
460
466
 
461
467
  DESCRIPTION
462
468
  Display the status and resources of the remote Stack deployment
@@ -475,6 +481,8 @@ EXAMPLES
475
481
  $ sanity blueprints info --stack <name-or-id>
476
482
 
477
483
  $ sanity blueprints info --project-id <id> --stack <name-or-id>
484
+
485
+ $ sanity blueprints info --organization-id <orgId> --stack <name-or-id>
478
486
  ```
479
487
 
480
488
  ## `sanity blueprints init [DIR]`
@@ -483,9 +491,8 @@ Initialize a Blueprint and create a remote Stack
483
491
 
484
492
  ```
485
493
  USAGE
486
- $ sanity blueprints init [DIR] [--json] [--validate-resources] [--dir <value>] [--example <value> |
487
- --blueprint-type json|js|ts | --stack-id <value> | --stack-name <value>] [--project-id <value>] [--organization-id
488
- <value>]
494
+ $ sanity blueprints init [DIR] [--json] [--dir <value>] [--example <value> | --blueprint-type json|js|ts |
495
+ --stack-id <value> | --stack-name <value>] [--project-id <value> | --organization-id <value>]
489
496
 
490
497
  ARGUMENTS
491
498
  [DIR] Directory to create the local Blueprint in
@@ -500,7 +507,6 @@ FLAGS
500
507
  --project-id=<value> Sanity project ID used to scope Blueprint and Stack
501
508
  --stack-id=<value> Existing Stack ID used to scope local Blueprint
502
509
  --stack-name=<value> Name to use for a new Stack provisioned during initialization
503
- --[no-]validate-resources Validate resources
504
510
 
505
511
  DESCRIPTION
506
512
  Initialize a Blueprint and create a remote Stack
@@ -534,20 +540,27 @@ Display logs for the current Blueprint's Stack deployment
534
540
 
535
541
  ```
536
542
  USAGE
537
- $ sanity blueprints logs [--json] [--validate-resources] [--stack <value>] [-w]
543
+ $ sanity blueprints logs [--json] [--stack <value>] [--project-id <value> | --organization-id <value>] [-l <value>
544
+ | -w] [--since <value> | ] [--before <value> | ]
538
545
 
539
546
  FLAGS
540
- -w, --watch Watch for new Stack logs (streaming mode)
547
+ -l, --limit=<value> Maximum number of log entries to retrieve (1-500)
548
+ -w, --watch Watch for new Stack logs
549
+ --before=<value> Only show logs before this ISO 8601 timestamp
541
550
  --json Format output as json
551
+ --organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
552
+ --project-id=<value> Sanity project ID used to scope Blueprint and Stack
553
+ --since=<value> Only show logs after this ISO 8601 timestamp
542
554
  --stack=<value> Stack name or ID to use instead of the locally configured Stack
543
- --[no-]validate-resources Validate resources
544
555
 
545
556
  DESCRIPTION
546
557
  Display logs for the current Blueprint's Stack deployment
547
558
 
548
559
  Retrieves Stack deployment logs, useful for debugging and monitoring deployment activity.
549
560
 
550
- Use --watch (-w) to stream logs in real-time.
561
+ Use --watch (-w) to tail logs in real-time.
562
+
563
+ Use --limit, --since, or --before to narrow the result set when not watching.
551
564
 
552
565
  If you're not seeing expected logs, verify your Stack is deployed with 'blueprints info'.
553
566
 
@@ -555,6 +568,57 @@ EXAMPLES
555
568
  $ sanity blueprints logs
556
569
 
557
570
  $ sanity blueprints logs --watch
571
+
572
+ $ sanity blueprints logs --stack <name-or-id>
573
+
574
+ $ sanity blueprints logs --limit 500
575
+
576
+ $ sanity blueprints logs --since 2026-05-01T00:00:00Z
577
+
578
+ $ sanity blueprints logs --before 2026-05-01T00:00:00Z
579
+ ```
580
+
581
+ ## `sanity blueprints mint-deploy-token`
582
+
583
+ Create a robot API token for deploying Blueprints from CI/CD
584
+
585
+ ```
586
+ USAGE
587
+ $ sanity blueprints mint-deploy-token [--project-id <value> | --organization-id <value>] [--label <value>] [-P |
588
+ --json]
589
+
590
+ FLAGS
591
+ -P, --print Print only the raw token to stdout (suitable for shell substitution)
592
+ --json Format output as json
593
+ --label=<value> Human-readable label for the robot. Defaults to a generated value.
594
+ --organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
595
+ --project-id=<value> Sanity project ID used to scope Blueprint and Stack
596
+
597
+ DESCRIPTION
598
+ Create a robot API token for deploying Blueprints from CI/CD
599
+
600
+ Mints a long-lived robot token with the role required to plan, deploy, and destroy Blueprints in this project or
601
+ organization.
602
+
603
+ By default the command runs interactively and asks how you want to receive the token (clipboard, print, or exit). Use
604
+ --print to emit only the raw token for shell pipelines, or --json for full API output.
605
+
606
+ The minted token is also visible in your Sanity Manage UI under Robots, where it can be revoked.
607
+
608
+ EXAMPLES
609
+ $ sanity blueprints mint-deploy-token
610
+
611
+ $ sanity blueprints mint-deploy-token --label "ci-deploy"
612
+
613
+ $ sanity blueprints mint-deploy-token --print
614
+
615
+ export SANITY_AUTH_TOKEN=$(sanity blueprints mint-deploy-token --print)
616
+
617
+ $ sanity blueprints mint-deploy-token --json
618
+
619
+ $ sanity blueprints mint-deploy-token --project-id <projectId>
620
+
621
+ $ sanity blueprints mint-deploy-token --organization-id <orgId>
558
622
  ```
559
623
 
560
624
  ## `sanity blueprints plan`
@@ -563,12 +627,13 @@ Preview changes that will be applied to the remote Stack
563
627
 
564
628
  ```
565
629
  USAGE
566
- $ sanity blueprints plan [--json] [--validate-resources] [--stack <value>]
630
+ $ sanity blueprints plan [--json] [--stack <value>] [--project-id <value> | --organization-id <value>]
567
631
 
568
632
  FLAGS
569
633
  --json Format output as json
634
+ --organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
635
+ --project-id=<value> Sanity project ID used to scope Blueprint and Stack
570
636
  --stack=<value> Stack name or ID to use instead of the locally configured Stack
571
- --[no-]validate-resources Validate resources
572
637
 
573
638
  DESCRIPTION
574
639
  Preview changes that will be applied to the remote Stack
@@ -581,6 +646,43 @@ DESCRIPTION
581
646
 
582
647
  EXAMPLES
583
648
  $ sanity blueprints plan
649
+
650
+ $ sanity blueprints plan --stack <name-or-id>
651
+
652
+ $ sanity blueprints plan --organization-id <orgId> --stack <name-or-id>
653
+ ```
654
+
655
+ ## `sanity blueprints promote`
656
+
657
+ Promote a Stack from project scope to organization scope
658
+
659
+ ```
660
+ USAGE
661
+ $ sanity blueprints promote [--json] [--stack <value>] [--project-id <value> | ] [--force] [--new-stack-name <value>]
662
+
663
+ FLAGS
664
+ --force Skip confirmation prompt
665
+ --json Format output as json
666
+ --new-stack-name=<value> Set a new name for the Stack while promoting
667
+ --project-id=<value> Sanity project ID used to scope Blueprint and Stack
668
+ --stack=<value> Stack name or ID to promote
669
+
670
+ DESCRIPTION
671
+ Promote a Stack from project scope to organization scope
672
+
673
+ Promotes a deployed Stack to organization scope, enabling management of org-level resources. Promotion cannot be
674
+ reversed.
675
+
676
+ Your local Blueprint configuration will be updated to reflect the new scope.
677
+
678
+ EXAMPLES
679
+ $ sanity blueprints promote
680
+
681
+ $ sanity blueprints promote --stack <name-or-id>
682
+
683
+ $ sanity blueprints promote --project-id <projectId> --stack <name-or-id>
684
+
685
+ $ sanity blueprints promote --new-stack-name <new-name>
584
686
  ```
585
687
 
586
688
  ## `sanity blueprints stacks`
@@ -589,15 +691,13 @@ List remote Stack deployments for your project or organization
589
691
 
590
692
  ```
591
693
  USAGE
592
- $ sanity blueprints stacks [--json] [--validate-resources] [--project-id <value> | --organization-id <value> |
593
- --include-projects]
694
+ $ sanity blueprints stacks [--json] [--project-id <value> | --organization-id <value> | --include-projects]
594
695
 
595
696
  FLAGS
596
697
  --include-projects Include Stacks from all projects within the organization. Requires --organization-id.
597
698
  --json Format output as json
598
699
  --organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
599
700
  --project-id=<value> Sanity project ID used to scope Blueprint and Stack
600
- --[no-]validate-resources Validate resources
601
701
 
602
702
  DESCRIPTION
603
703
  List remote Stack deployments for your project or organization
@@ -1762,28 +1862,27 @@ Add a Function to your Blueprint
1762
1862
 
1763
1863
  ```
1764
1864
  USAGE
1765
- $ sanity functions add [--json] [--validate-resources] [--example <value> | -n <value> | | --language ts|js |
1766
- --javascript | | ] [--type document-publish|document-create|document-delete|document-update|media-library-asset-cre
1767
- ate|media-library-asset-delete|media-library-asset-update|scheduled-function|sync-tag-invalidate... ] [--helpers]
1768
- [--installer skip|npm|pnpm|yarn] [-i | ]
1865
+ $ sanity functions add [--json] [--example <value> | -n <value> | | --language ts|js | --javascript | | ]
1866
+ [--type document-publish|document-create|document-delete|document-update|media-library-asset-create|media-library-as
1867
+ set-delete|media-library-asset-update|scheduled-function|sync-tag-invalidate... ] [--helpers] [--installer
1868
+ skip|npm|pnpm|yarn] [-i | ]
1769
1869
 
1770
1870
  FLAGS
1771
- -i, --install Shortcut for --fn-installer npm
1772
- -n, --name=<value> Name of the Function to add
1773
- --example=<value> Example to use for the Function
1774
- --[no-]helpers Add helpers to the new Function
1775
- --installer=<option> How to install the @sanity/functions helpers
1776
- <options: skip|npm|pnpm|yarn>
1777
- --javascript Use JavaScript instead of TypeScript
1778
- --json Format output as json
1779
- --language=<option> [default: ts] Language of the new Function
1780
- <options: ts|js>
1781
- --type=<option>... Document change event(s) that should trigger the function; you can specify multiple
1782
- events by specifying this flag multiple times
1783
- <options: document-publish|document-create|document-delete|document-update|media-librar
1784
- y-asset-create|media-library-asset-delete|media-library-asset-update|scheduled-function
1785
- |sync-tag-invalidate>
1786
- --[no-]validate-resources Validate resources
1871
+ -i, --install Shortcut for --fn-installer npm
1872
+ -n, --name=<value> Name of the Function to add
1873
+ --example=<value> Example to use for the Function
1874
+ --[no-]helpers Add helpers to the new Function
1875
+ --installer=<option> How to install the @sanity/functions helpers
1876
+ <options: skip|npm|pnpm|yarn>
1877
+ --javascript Use JavaScript instead of TypeScript
1878
+ --json Format output as json
1879
+ --language=<option> [default: ts] Language of the new Function
1880
+ <options: ts|js>
1881
+ --type=<option>... Document change event(s) that should trigger the function; you can specify multiple events
1882
+ by specifying this flag multiple times
1883
+ <options: document-publish|document-create|document-delete|document-update|media-library-ass
1884
+ et-create|media-library-asset-delete|media-library-asset-update|scheduled-function|sync-tag-
1885
+ invalidate>
1787
1886
 
1788
1887
  DESCRIPTION
1789
1888
  Add a Function to your Blueprint
@@ -1813,15 +1912,14 @@ Start the Sanity Function emulator
1813
1912
 
1814
1913
  ```
1815
1914
  USAGE
1816
- $ sanity functions dev [--json] [--validate-resources] [-h <value>] [-p <value>] [-t <value>]
1915
+ $ sanity functions dev [--json] [-h <value>] [-p <value>] [-t <value>]
1817
1916
 
1818
1917
  FLAGS
1819
- -h, --host=<value> The local network interface at which to listen. [default: "localhost"]
1820
- -p, --port=<value> TCP port to start emulator on. [default: 8080]
1821
- -t, --timeout=<value> Maximum execution time for all functions, in seconds. Takes precedence over
1822
- function-specific `timeout`
1823
- --json Format output as json
1824
- --[no-]validate-resources Validate resources
1918
+ -h, --host=<value> The local network interface at which to listen. [default: "localhost"]
1919
+ -p, --port=<value> TCP port to start emulator on. [default: 8080]
1920
+ -t, --timeout=<value> Maximum execution time for all functions, in seconds. Takes precedence over function-specific
1921
+ `timeout`
1922
+ --json Format output as json
1825
1923
 
1826
1924
  DESCRIPTION
1827
1925
  Start the Sanity Function emulator
@@ -1847,7 +1945,7 @@ Add or set an environment variable for a deployed function
1847
1945
 
1848
1946
  ```
1849
1947
  USAGE
1850
- $ sanity functions env add NAME KEY VALUE [--json] [--validate-resources]
1948
+ $ sanity functions env add NAME KEY VALUE [--json]
1851
1949
 
1852
1950
  ARGUMENTS
1853
1951
  NAME The name of the Sanity Function
@@ -1855,8 +1953,7 @@ ARGUMENTS
1855
1953
  VALUE The value of the environment variable
1856
1954
 
1857
1955
  FLAGS
1858
- --json Format output as json
1859
- --[no-]validate-resources Validate resources
1956
+ --json Format output as json
1860
1957
 
1861
1958
  DESCRIPTION
1862
1959
  Add or set an environment variable for a deployed function
@@ -1876,14 +1973,13 @@ List environment variables for a deployed function
1876
1973
 
1877
1974
  ```
1878
1975
  USAGE
1879
- $ sanity functions env list NAME [--json] [--validate-resources]
1976
+ $ sanity functions env list NAME [--json]
1880
1977
 
1881
1978
  ARGUMENTS
1882
1979
  NAME The name of the Sanity Function
1883
1980
 
1884
1981
  FLAGS
1885
- --json Format output as json
1886
- --[no-]validate-resources Validate resources
1982
+ --json Format output as json
1887
1983
 
1888
1984
  DESCRIPTION
1889
1985
  List environment variables for a deployed function
@@ -1902,15 +1998,14 @@ Remove an environment variable from a deployed function
1902
1998
 
1903
1999
  ```
1904
2000
  USAGE
1905
- $ sanity functions env remove NAME KEY [--json] [--validate-resources]
2001
+ $ sanity functions env remove NAME KEY [--json]
1906
2002
 
1907
2003
  ARGUMENTS
1908
2004
  NAME The name of the Sanity Function
1909
2005
  KEY The name of the environment variable
1910
2006
 
1911
2007
  FLAGS
1912
- --json Format output as json
1913
- --[no-]validate-resources Validate resources
2008
+ --json Format output as json
1914
2009
 
1915
2010
  DESCRIPTION
1916
2011
  Remove an environment variable from a deployed function
@@ -1930,20 +2025,19 @@ Retrieve or delete logs for a Sanity Function
1930
2025
 
1931
2026
  ```
1932
2027
  USAGE
1933
- $ sanity functions logs [NAME] [--validate-resources] [--stack <value>] [-u] [-f [-d | -l <value> | --json]] [-w]
2028
+ $ sanity functions logs [NAME] [--stack <value>] [-u] [-f [-d | -l <value> | --json]] [-w]
1934
2029
 
1935
2030
  ARGUMENTS
1936
2031
  [NAME] The name of the Sanity Function
1937
2032
 
1938
2033
  FLAGS
1939
- -d, --delete Delete all logs for the function
1940
- -f, --force Skip confirmation for deleting logs
1941
- -l, --limit=<value> [default: 50] Total number of log entries to retrieve
1942
- -u, --utc Show dates in UTC time zone
1943
- -w, --watch Watch for new logs (streaming mode)
1944
- --json Format output as json
1945
- --stack=<value> Stack name or ID to use instead of the locally configured Stack
1946
- --[no-]validate-resources Validate resources
2034
+ -d, --delete Delete all logs for the function
2035
+ -f, --force Skip confirmation for deleting logs
2036
+ -l, --limit=<value> [default: 50] Total number of log entries to retrieve
2037
+ -u, --utc Show dates in UTC time zone
2038
+ -w, --watch Watch for new logs (streaming mode)
2039
+ --json Format output as json
2040
+ --stack=<value> Stack name or ID to use instead of the locally configured Stack
1947
2041
 
1948
2042
  DESCRIPTION
1949
2043
  Retrieve or delete logs for a Sanity Function
@@ -1969,11 +2063,10 @@ Invoke a local Sanity Function
1969
2063
 
1970
2064
  ```
1971
2065
  USAGE
1972
- $ sanity functions test [NAME] [--json] [--validate-resources] [--organization-id <value>] [--data-before <value>
1973
- | [-d <value> | -f <value> | --document-id <value>] | | | --file-before <value> | --file-after <value> |
1974
- --document-id-before <value> | --document-id-after <value>] [--data-after <value> | | | | | | | ] [-e
1975
- create|update|delete] [-t <value>] [-a <value>] [--with-user-token] [--media-library-id <value> | --project-id
1976
- <value> | --dataset <value>]
2066
+ $ sanity functions test [NAME] [--json] [--data-before <value> | [-d <value> | -f <value> | --document-id <value>]
2067
+ | | | --file-before <value> | --file-after <value> | --document-id-before <value> | --document-id-after <value>]
2068
+ [--data-after <value> | | | | | | | ] [-e create|update|delete] [-t <value>] [-a <value>] [--with-user-token]
2069
+ [--media-library-id <value> | [--project-id <value> | --organization-id <value>] | --dataset <value>]
1977
2070
 
1978
2071
  ARGUMENTS
1979
2072
  [NAME] The name of the Sanity Function
@@ -1997,7 +2090,6 @@ FLAGS
1997
2090
  --media-library-id=<value> Sanity Media Library ID to use
1998
2091
  --organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
1999
2092
  --project-id=<value> Sanity project ID used to scope Blueprint and Stack
2000
- --[no-]validate-resources Validate resources
2001
2093
  --with-user-token Prime access token from CLI config
2002
2094
 
2003
2095
  DESCRIPTION
@@ -1,13 +1,12 @@
1
1
  import { rm } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { styleText } from 'node:util';
4
- import { getCliTelemetry, getTimer, isInteractive } from '@sanity/cli-core';
4
+ import { getCliTelemetry, getLocalPackageVersion, getTimer, isInteractive } from '@sanity/cli-core';
5
5
  import { confirm, logSymbols, spinner } from '@sanity/cli-core/ux';
6
6
  import { parse as semverParse } from 'semver';
7
7
  import { AppBuildTrace } from '../../telemetry/build.telemetry.js';
8
8
  import { getAppId } from '../../util/appId.js';
9
9
  import { compareDependencyVersions } from '../../util/compareDependencyVersions.js';
10
- import { getLocalPackageVersion } from '../../util/getLocalPackageVersion.js';
11
10
  import { formatModuleSizes, sortModulesBySize } from '../../util/moduleFormatUtils.js';
12
11
  import { warnAboutMissingAppId } from '../../util/warnAboutMissingAppId.js';
13
12
  import { buildDebug } from './buildDebug.js';
@@ -23,12 +22,35 @@ import { handlePrereleaseVersions } from './handlePrereleaseVersions.js';
23
22
  * @internal
24
23
  */ export async function buildApp(options) {
25
24
  const { cliConfig, flags, outDir, output, workDir } = options;
25
+ await internalBuildApp({
26
+ appId: getAppId(cliConfig),
27
+ appTitle: cliConfig && 'app' in cliConfig ? cliConfig.app?.title : undefined,
28
+ autoUpdatesEnabled: options.autoUpdatesEnabled,
29
+ calledFromDeploy: options.calledFromDeploy,
30
+ determineBasePath: ()=>determineBasePath(cliConfig, 'app', output),
31
+ entry: cliConfig && 'app' in cliConfig ? cliConfig.app?.entry : undefined,
32
+ minify: flags.minify,
33
+ outDir,
34
+ output,
35
+ reactCompiler: cliConfig && 'reactCompiler' in cliConfig ? cliConfig.reactCompiler : undefined,
36
+ schemaExtraction: cliConfig?.schemaExtraction,
37
+ sourceMap: Boolean(flags['source-maps']),
38
+ stats: flags.stats,
39
+ unattendedMode: flags.yes,
40
+ vite: cliConfig.vite,
41
+ workDir
42
+ });
43
+ }
44
+ /**
45
+ * Internal build app that avoids depending on flags for CLI config.
46
+ * @param options - options for the build
47
+ */ async function internalBuildApp(options) {
48
+ const { appId, determineBasePath, outDir, output, workDir } = options;
26
49
  let { autoUpdatesEnabled } = options;
27
- const unattendedMode = flags.yes;
50
+ const unattendedMode = options.unattendedMode;
28
51
  const timer = getTimer();
29
52
  const defaultOutputDir = path.resolve(path.join(workDir, 'dist'));
30
53
  const outputDir = path.resolve(outDir || defaultOutputDir);
31
- const appId = getAppId(cliConfig);
32
54
  const installedSdkVersion = await getLocalPackageVersion('@sanity/sdk-react', workDir);
33
55
  const installedSanityVersion = await getLocalPackageVersion('sanity', workDir);
34
56
  if (!installedSdkVersion) {
@@ -130,8 +152,7 @@ import { handlePrereleaseVersions } from './handlePrereleaseVersions.js';
130
152
  message: `Do you want to delete the existing directory (${outputDir}) first?`
131
153
  });
132
154
  }
133
- // Determine base path for built app
134
- const basePath = determineBasePath(cliConfig, 'app', output);
155
+ const basePath = determineBasePath();
135
156
  let spin;
136
157
  if (shouldClean) {
137
158
  timer.start('cleanOutputFolder');
@@ -164,19 +185,19 @@ import { handlePrereleaseVersions } from './handlePrereleaseVersions.js';
164
185
  try {
165
186
  timer.start('bundleStudio');
166
187
  const bundle = await buildStaticFiles({
167
- appTitle: cliConfig && 'app' in cliConfig ? cliConfig.app?.title : undefined,
188
+ appTitle: options.appTitle,
168
189
  autoUpdatesCssUrls: autoUpdatesCssUrls.length > 0 ? autoUpdatesCssUrls : undefined,
169
190
  basePath,
170
191
  cwd: workDir,
171
- entry: cliConfig && 'app' in cliConfig ? cliConfig.app?.entry : undefined,
192
+ entry: options.entry,
172
193
  importMap,
173
194
  isApp: true,
174
- minify: Boolean(flags.minify),
195
+ minify: options.minify,
175
196
  outputDir,
176
- reactCompiler: cliConfig && 'reactCompiler' in cliConfig ? cliConfig.reactCompiler : undefined,
177
- schemaExtraction: cliConfig?.schemaExtraction,
178
- sourceMap: Boolean(flags['source-maps']),
179
- vite: cliConfig && 'vite' in cliConfig ? cliConfig.vite : undefined
197
+ reactCompiler: options.reactCompiler,
198
+ schemaExtraction: options.schemaExtraction,
199
+ sourceMap: options.sourceMap,
200
+ vite: options.vite
180
201
  });
181
202
  trace.log({
182
203
  outputSize: bundle.chunks.flatMap((chunk)=>chunk.modules.flatMap((mod)=>mod.renderedLength)).reduce((sum, n)=>sum + n, 0)
@@ -184,7 +205,7 @@ import { handlePrereleaseVersions } from './handlePrereleaseVersions.js';
184
205
  const buildDuration = timer.end('bundleStudio');
185
206
  spin.text = `Build Sanity application (${buildDuration.toFixed(0)}ms)`;
186
207
  spin.succeed();
187
- if (flags.stats) {
208
+ if (options.stats) {
188
209
  output.log('\nLargest module files:');
189
210
  output.log(formatModuleSizes(sortModulesBySize(bundle.chunks).slice(0, 15)));
190
211
  }