@sanity/cli 6.1.4 → 6.1.5

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.
package/README.md CHANGED
@@ -140,7 +140,7 @@ EXAMPLES
140
140
  $ sanity backup disable production
141
141
  ```
142
142
 
143
- _See code: [src/commands/backup/disable.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/backup/disable.ts)_
143
+ _See code: [src/commands/backup/disable.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/backup/disable.ts)_
144
144
 
145
145
  ## `sanity backup download [DATASET]`
146
146
 
@@ -184,7 +184,7 @@ EXAMPLES
184
184
  $ sanity backup download production --backup-id 2024-01-01-backup-3 --out /path/to/file --overwrite
185
185
  ```
186
186
 
187
- _See code: [src/commands/backup/download.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/backup/download.ts)_
187
+ _See code: [src/commands/backup/download.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/backup/download.ts)_
188
188
 
189
189
  ## `sanity backup enable [DATASET]`
190
190
 
@@ -213,7 +213,7 @@ EXAMPLES
213
213
  $ sanity backup enable production
214
214
  ```
215
215
 
216
- _See code: [src/commands/backup/enable.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/backup/enable.ts)_
216
+ _See code: [src/commands/backup/enable.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/backup/enable.ts)_
217
217
 
218
218
  ## `sanity backup list [DATASET]`
219
219
 
@@ -255,7 +255,7 @@ EXAMPLES
255
255
  $ sanity backup list production --after 2024-01-31 --limit 10
256
256
  ```
257
257
 
258
- _See code: [src/commands/backup/list.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/backup/list.ts)_
258
+ _See code: [src/commands/backup/list.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/backup/list.ts)_
259
259
 
260
260
  ## `sanity blueprints add TYPE`
261
261
 
@@ -630,7 +630,7 @@ EXAMPLES
630
630
  $ sanity build --no-minify --source-maps
631
631
  ```
632
632
 
633
- _See code: [src/commands/build.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/build.ts)_
633
+ _See code: [src/commands/build.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/build.ts)_
634
634
 
635
635
  ## `sanity codemod [CODEMODNAME]`
636
636
 
@@ -661,7 +661,7 @@ EXAMPLES
661
661
  $ sanity codemod reactIconsV3 --dry
662
662
  ```
663
663
 
664
- _See code: [src/commands/codemod.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/codemod.ts)_
664
+ _See code: [src/commands/codemod.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/codemod.ts)_
665
665
 
666
666
  ## `sanity cors add ORIGIN`
667
667
 
@@ -701,7 +701,7 @@ EXAMPLES
701
701
  $ sanity cors add https://myapp.com --project-id abc123
702
702
  ```
703
703
 
704
- _See code: [src/commands/cors/add.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/cors/add.ts)_
704
+ _See code: [src/commands/cors/add.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/cors/add.ts)_
705
705
 
706
706
  ## `sanity cors delete [ORIGIN]`
707
707
 
@@ -734,7 +734,7 @@ EXAMPLES
734
734
  $ sanity cors delete --project-id abc123
735
735
  ```
736
736
 
737
- _See code: [src/commands/cors/delete.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/cors/delete.ts)_
737
+ _See code: [src/commands/cors/delete.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/cors/delete.ts)_
738
738
 
739
739
  ## `sanity cors list`
740
740
 
@@ -760,7 +760,7 @@ EXAMPLES
760
760
  $ sanity cors list --project-id abc123
761
761
  ```
762
762
 
763
- _See code: [src/commands/cors/list.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/cors/list.ts)_
763
+ _See code: [src/commands/cors/list.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/cors/list.ts)_
764
764
 
765
765
  ## `sanity dataset alias create [ALIASNAME] [TARGETDATASET]`
766
766
 
@@ -802,7 +802,7 @@ EXAMPLES
802
802
  $ sanity dataset alias create ~conference conf-2025
803
803
  ```
804
804
 
805
- _See code: [src/commands/dataset/alias/create.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/dataset/alias/create.ts)_
805
+ _See code: [src/commands/dataset/alias/create.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/dataset/alias/create.ts)_
806
806
 
807
807
  ## `sanity dataset alias delete ALIASNAME`
808
808
 
@@ -838,7 +838,7 @@ EXAMPLES
838
838
  $ sanity dataset alias delete conference --force
839
839
  ```
840
840
 
841
- _See code: [src/commands/dataset/alias/delete.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/dataset/alias/delete.ts)_
841
+ _See code: [src/commands/dataset/alias/delete.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/dataset/alias/delete.ts)_
842
842
 
843
843
  ## `sanity dataset alias link [ALIASNAME] [TARGETDATASET]`
844
844
 
@@ -883,7 +883,7 @@ EXAMPLES
883
883
  $ sanity dataset alias link conference conf-2025 --force
884
884
  ```
885
885
 
886
- _See code: [src/commands/dataset/alias/link.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/dataset/alias/link.ts)_
886
+ _See code: [src/commands/dataset/alias/link.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/dataset/alias/link.ts)_
887
887
 
888
888
  ## `sanity dataset alias unlink [ALIASNAME]`
889
889
 
@@ -923,7 +923,7 @@ EXAMPLES
923
923
  $ sanity dataset alias unlink conference --force
924
924
  ```
925
925
 
926
- _See code: [src/commands/dataset/alias/unlink.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/dataset/alias/unlink.ts)_
926
+ _See code: [src/commands/dataset/alias/unlink.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/dataset/alias/unlink.ts)_
927
927
 
928
928
  ## `sanity dataset copy [SOURCE] [TARGET]`
929
929
 
@@ -987,7 +987,7 @@ EXAMPLES
987
987
  $ sanity dataset copy --list --offset 2 --limit 10
988
988
  ```
989
989
 
990
- _See code: [src/commands/dataset/copy.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/dataset/copy.ts)_
990
+ _See code: [src/commands/dataset/copy.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/dataset/copy.ts)_
991
991
 
992
992
  ## `sanity dataset create [NAME]`
993
993
 
@@ -1027,7 +1027,7 @@ EXAMPLES
1027
1027
  $ sanity dataset create my-dataset --visibility private
1028
1028
  ```
1029
1029
 
1030
- _See code: [src/commands/dataset/create.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/dataset/create.ts)_
1030
+ _See code: [src/commands/dataset/create.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/dataset/create.ts)_
1031
1031
 
1032
1032
  ## `sanity dataset delete DATASETNAME`
1033
1033
 
@@ -1059,7 +1059,7 @@ EXAMPLES
1059
1059
  $ sanity dataset delete my-dataset --force
1060
1060
  ```
1061
1061
 
1062
- _See code: [src/commands/dataset/delete.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/dataset/delete.ts)_
1062
+ _See code: [src/commands/dataset/delete.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/dataset/delete.ts)_
1063
1063
 
1064
1064
  ## `sanity dataset embeddings disable [DATASET]`
1065
1065
 
@@ -1084,7 +1084,7 @@ EXAMPLES
1084
1084
  $ sanity dataset embeddings disable production
1085
1085
  ```
1086
1086
 
1087
- _See code: [src/commands/dataset/embeddings/disable.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/dataset/embeddings/disable.ts)_
1087
+ _See code: [src/commands/dataset/embeddings/disable.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/dataset/embeddings/disable.ts)_
1088
1088
 
1089
1089
  ## `sanity dataset embeddings enable [DATASET]`
1090
1090
 
@@ -1121,7 +1121,7 @@ EXAMPLES
1121
1121
  $ sanity dataset embeddings enable production --wait
1122
1122
  ```
1123
1123
 
1124
- _See code: [src/commands/dataset/embeddings/enable.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/dataset/embeddings/enable.ts)_
1124
+ _See code: [src/commands/dataset/embeddings/enable.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/dataset/embeddings/enable.ts)_
1125
1125
 
1126
1126
  ## `sanity dataset embeddings status [DATASET]`
1127
1127
 
@@ -1146,7 +1146,7 @@ EXAMPLES
1146
1146
  $ sanity dataset embeddings status production
1147
1147
  ```
1148
1148
 
1149
- _See code: [src/commands/dataset/embeddings/status.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/dataset/embeddings/status.ts)_
1149
+ _See code: [src/commands/dataset/embeddings/status.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/dataset/embeddings/status.ts)_
1150
1150
 
1151
1151
  ## `sanity dataset export [NAME] [DESTINATION]`
1152
1152
 
@@ -1199,7 +1199,7 @@ EXAMPLES
1199
1199
  $ sanity dataset export staging staging.tar.gz --types products,shops
1200
1200
  ```
1201
1201
 
1202
- _See code: [src/commands/dataset/export.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/dataset/export.ts)_
1202
+ _See code: [src/commands/dataset/export.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/dataset/export.ts)_
1203
1203
 
1204
1204
  ## `sanity dataset import SOURCE [TARGETDATASET]`
1205
1205
 
@@ -1248,7 +1248,7 @@ EXAMPLES
1248
1248
  $ sanity dataset import -p projectId -d staging -t someSecretToken my-dataset.ndjson
1249
1249
  ```
1250
1250
 
1251
- _See code: [src/commands/dataset/import.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/dataset/import.ts)_
1251
+ _See code: [src/commands/dataset/import.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/dataset/import.ts)_
1252
1252
 
1253
1253
  ## `sanity dataset list`
1254
1254
 
@@ -1274,7 +1274,7 @@ EXAMPLES
1274
1274
  $ sanity dataset list --project-id abc123
1275
1275
  ```
1276
1276
 
1277
- _See code: [src/commands/dataset/list.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/dataset/list.ts)_
1277
+ _See code: [src/commands/dataset/list.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/dataset/list.ts)_
1278
1278
 
1279
1279
  ## `sanity dataset visibility get DATASET`
1280
1280
 
@@ -1299,7 +1299,7 @@ EXAMPLES
1299
1299
  $ sanity dataset visibility get my-dataset
1300
1300
  ```
1301
1301
 
1302
- _See code: [src/commands/dataset/visibility/get.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/dataset/visibility/get.ts)_
1302
+ _See code: [src/commands/dataset/visibility/get.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/dataset/visibility/get.ts)_
1303
1303
 
1304
1304
  ## `sanity dataset visibility set DATASET MODE`
1305
1305
 
@@ -1329,7 +1329,7 @@ EXAMPLES
1329
1329
  $ sanity dataset visibility set my-dataset public
1330
1330
  ```
1331
1331
 
1332
- _See code: [src/commands/dataset/visibility/set.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/dataset/visibility/set.ts)_
1332
+ _See code: [src/commands/dataset/visibility/set.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/dataset/visibility/set.ts)_
1333
1333
 
1334
1334
  ## `sanity debug`
1335
1335
 
@@ -1351,7 +1351,7 @@ EXAMPLES
1351
1351
  $ sanity debug --secrets
1352
1352
  ```
1353
1353
 
1354
- _See code: [src/commands/debug.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/debug.ts)_
1354
+ _See code: [src/commands/debug.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/debug.ts)_
1355
1355
 
1356
1356
  ## `sanity deploy [SOURCEDIR]`
1357
1357
 
@@ -1396,7 +1396,7 @@ EXAMPLES
1396
1396
  $ sanity deploy --external
1397
1397
  ```
1398
1398
 
1399
- _See code: [src/commands/deploy.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/deploy.ts)_
1399
+ _See code: [src/commands/deploy.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/deploy.ts)_
1400
1400
 
1401
1401
  ## `sanity dev`
1402
1402
 
@@ -1423,7 +1423,7 @@ EXAMPLES
1423
1423
  $ sanity dev --load-in-dashboard
1424
1424
  ```
1425
1425
 
1426
- _See code: [src/commands/dev.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/dev.ts)_
1426
+ _See code: [src/commands/dev.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/dev.ts)_
1427
1427
 
1428
1428
  ## `sanity docs browse`
1429
1429
 
@@ -1437,7 +1437,7 @@ DESCRIPTION
1437
1437
  Open Sanity docs in a web browser
1438
1438
  ```
1439
1439
 
1440
- _See code: [src/commands/docs/browse.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/docs/browse.ts)_
1440
+ _See code: [src/commands/docs/browse.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/docs/browse.ts)_
1441
1441
 
1442
1442
  ## `sanity docs read PATH`
1443
1443
 
@@ -1474,7 +1474,7 @@ EXAMPLES
1474
1474
  $ sanity docs read https://www.sanity.io/docs/studio/installation -w
1475
1475
  ```
1476
1476
 
1477
- _See code: [src/commands/docs/read.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/docs/read.ts)_
1477
+ _See code: [src/commands/docs/read.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/docs/read.ts)_
1478
1478
 
1479
1479
  ## `sanity docs search QUERY`
1480
1480
 
@@ -1507,7 +1507,7 @@ EXAMPLES
1507
1507
  $ sanity docs search "deployment" --limit=5
1508
1508
  ```
1509
1509
 
1510
- _See code: [src/commands/docs/search.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/docs/search.ts)_
1510
+ _See code: [src/commands/docs/search.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/docs/search.ts)_
1511
1511
 
1512
1512
  ## `sanity doctor [CHECKS]`
1513
1513
 
@@ -1538,7 +1538,7 @@ EXAMPLES
1538
1538
  $ sanity doctor cli
1539
1539
  ```
1540
1540
 
1541
- _See code: [src/commands/doctor.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/doctor.ts)_
1541
+ _See code: [src/commands/doctor.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/doctor.ts)_
1542
1542
 
1543
1543
  ## `sanity documents create [FILE]`
1544
1544
 
@@ -1589,7 +1589,7 @@ EXAMPLES
1589
1589
  $ sanity documents create myDocument.json --project-id abc123
1590
1590
  ```
1591
1591
 
1592
- _See code: [src/commands/documents/create.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/documents/create.ts)_
1592
+ _See code: [src/commands/documents/create.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/documents/create.ts)_
1593
1593
 
1594
1594
  ## `sanity documents delete ID [IDS]`
1595
1595
 
@@ -1632,7 +1632,7 @@ EXAMPLES
1632
1632
  $ sanity documents delete myDocId --project-id abc123
1633
1633
  ```
1634
1634
 
1635
- _See code: [src/commands/documents/delete.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/documents/delete.ts)_
1635
+ _See code: [src/commands/documents/delete.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/documents/delete.ts)_
1636
1636
 
1637
1637
  ## `sanity documents get DOCUMENTID`
1638
1638
 
@@ -1673,7 +1673,7 @@ EXAMPLES
1673
1673
  $ sanity documents get myDocId --project-id abc123
1674
1674
  ```
1675
1675
 
1676
- _See code: [src/commands/documents/get.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/documents/get.ts)_
1676
+ _See code: [src/commands/documents/get.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/documents/get.ts)_
1677
1677
 
1678
1678
  ## `sanity documents query QUERY`
1679
1679
 
@@ -1716,7 +1716,7 @@ EXAMPLES
1716
1716
  $ sanity documents query '*[_type == "post"]' --project-id abc123 --dataset production
1717
1717
  ```
1718
1718
 
1719
- _See code: [src/commands/documents/query.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/documents/query.ts)_
1719
+ _See code: [src/commands/documents/query.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/documents/query.ts)_
1720
1720
 
1721
1721
  ## `sanity documents validate`
1722
1722
 
@@ -1770,7 +1770,7 @@ EXAMPLES
1770
1770
  $ sanity documents validate --project-id abc123 --dataset production
1771
1771
  ```
1772
1772
 
1773
- _See code: [src/commands/documents/validate.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/documents/validate.ts)_
1773
+ _See code: [src/commands/documents/validate.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/documents/validate.ts)_
1774
1774
 
1775
1775
  ## `sanity exec SCRIPT`
1776
1776
 
@@ -1811,7 +1811,7 @@ EXAMPLES
1811
1811
  $ sanity exec --mock-browser-env myscript.js -- --dry-run positional-argument
1812
1812
  ```
1813
1813
 
1814
- _See code: [src/commands/exec.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/exec.ts)_
1814
+ _See code: [src/commands/exec.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/exec.ts)_
1815
1815
 
1816
1816
  ## `sanity functions add`
1817
1817
 
@@ -2110,7 +2110,7 @@ EXAMPLES
2110
2110
  $ sanity graphql deploy --playground
2111
2111
  ```
2112
2112
 
2113
- _See code: [src/commands/graphql/deploy.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/graphql/deploy.ts)_
2113
+ _See code: [src/commands/graphql/deploy.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/graphql/deploy.ts)_
2114
2114
 
2115
2115
  ## `sanity graphql list`
2116
2116
 
@@ -2136,7 +2136,7 @@ EXAMPLES
2136
2136
  $ sanity graphql list --project-id abc123
2137
2137
  ```
2138
2138
 
2139
- _See code: [src/commands/graphql/list.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/graphql/list.ts)_
2139
+ _See code: [src/commands/graphql/list.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/graphql/list.ts)_
2140
2140
 
2141
2141
  ## `sanity graphql undeploy`
2142
2142
 
@@ -2184,7 +2184,7 @@ EXAMPLES
2184
2184
  $ sanity graphql undeploy --project-id abc123 --dataset production
2185
2185
  ```
2186
2186
 
2187
- _See code: [src/commands/graphql/undeploy.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/graphql/undeploy.ts)_
2187
+ _See code: [src/commands/graphql/undeploy.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/graphql/undeploy.ts)_
2188
2188
 
2189
2189
  ## `sanity help [COMMAND]`
2190
2190
 
@@ -2233,7 +2233,7 @@ EXAMPLES
2233
2233
  $ sanity hook attempt abc123 --project-id projectId
2234
2234
  ```
2235
2235
 
2236
- _See code: [src/commands/hook/attempt.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/hook/attempt.ts)_
2236
+ _See code: [src/commands/hook/attempt.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/hook/attempt.ts)_
2237
2237
 
2238
2238
  ## `sanity hook create`
2239
2239
 
@@ -2259,7 +2259,7 @@ EXAMPLES
2259
2259
  $ sanity hook create --project-id abc123
2260
2260
  ```
2261
2261
 
2262
- _See code: [src/commands/hook/create.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/hook/create.ts)_
2262
+ _See code: [src/commands/hook/create.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/hook/create.ts)_
2263
2263
 
2264
2264
  ## `sanity hook delete [NAME]`
2265
2265
 
@@ -2292,7 +2292,7 @@ EXAMPLES
2292
2292
  $ sanity hook delete --project-id abc123
2293
2293
  ```
2294
2294
 
2295
- _See code: [src/commands/hook/delete.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/hook/delete.ts)_
2295
+ _See code: [src/commands/hook/delete.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/hook/delete.ts)_
2296
2296
 
2297
2297
  ## `sanity hook list`
2298
2298
 
@@ -2318,7 +2318,7 @@ EXAMPLES
2318
2318
  $ sanity hook list --project-id abc123
2319
2319
  ```
2320
2320
 
2321
- _See code: [src/commands/hook/list.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/hook/list.ts)_
2321
+ _See code: [src/commands/hook/list.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/hook/list.ts)_
2322
2322
 
2323
2323
  ## `sanity hook logs [NAME]`
2324
2324
 
@@ -2354,7 +2354,7 @@ EXAMPLES
2354
2354
  $ sanity hook logs --project-id abc123
2355
2355
  ```
2356
2356
 
2357
- _See code: [src/commands/hook/logs.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/hook/logs.ts)_
2357
+ _See code: [src/commands/hook/logs.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/hook/logs.ts)_
2358
2358
 
2359
2359
  ## `sanity init`
2360
2360
 
@@ -2423,7 +2423,7 @@ EXAMPLES
2423
2423
  --output-path /Users/espenh/movies-unlimited
2424
2424
  ```
2425
2425
 
2426
- _See code: [src/commands/init.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/init.ts)_
2426
+ _See code: [src/commands/init.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/init.ts)_
2427
2427
 
2428
2428
  ## `sanity install [PACKAGES]`
2429
2429
 
@@ -2447,7 +2447,7 @@ EXAMPLES
2447
2447
  $ sanity install some-package another-package
2448
2448
  ```
2449
2449
 
2450
- _See code: [src/commands/install.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/install.ts)_
2450
+ _See code: [src/commands/install.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/install.ts)_
2451
2451
 
2452
2452
  ## `sanity learn`
2453
2453
 
@@ -2461,7 +2461,7 @@ DESCRIPTION
2461
2461
  Opens Sanity Learn in your web browser
2462
2462
  ```
2463
2463
 
2464
- _See code: [src/commands/learn.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/learn.ts)_
2464
+ _See code: [src/commands/learn.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/learn.ts)_
2465
2465
 
2466
2466
  ## `sanity login`
2467
2467
 
@@ -2493,7 +2493,7 @@ EXAMPLES
2493
2493
  $ sanity login --provider github --no-open
2494
2494
  ```
2495
2495
 
2496
- _See code: [src/commands/login.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/login.ts)_
2496
+ _See code: [src/commands/login.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/login.ts)_
2497
2497
 
2498
2498
  ## `sanity logout`
2499
2499
 
@@ -2507,7 +2507,7 @@ DESCRIPTION
2507
2507
  Logs out the CLI from the current user session
2508
2508
  ```
2509
2509
 
2510
- _See code: [src/commands/logout.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/logout.ts)_
2510
+ _See code: [src/commands/logout.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/logout.ts)_
2511
2511
 
2512
2512
  ## `sanity manage`
2513
2513
 
@@ -2521,7 +2521,7 @@ DESCRIPTION
2521
2521
  Opens project management interface in your web browser
2522
2522
  ```
2523
2523
 
2524
- _See code: [src/commands/manage.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/manage.ts)_
2524
+ _See code: [src/commands/manage.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/manage.ts)_
2525
2525
 
2526
2526
  ## `sanity manifest extract`
2527
2527
 
@@ -2549,7 +2549,7 @@ EXAMPLES
2549
2549
  $ sanity manifest extract --path /public/static
2550
2550
  ```
2551
2551
 
2552
- _See code: [src/commands/manifest/extract.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/manifest/extract.ts)_
2552
+ _See code: [src/commands/manifest/extract.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/manifest/extract.ts)_
2553
2553
 
2554
2554
  ## `sanity mcp configure`
2555
2555
 
@@ -2568,7 +2568,7 @@ EXAMPLES
2568
2568
  $ sanity mcp configure
2569
2569
  ```
2570
2570
 
2571
- _See code: [src/commands/mcp/configure.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/mcp/configure.ts)_
2571
+ _See code: [src/commands/mcp/configure.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/mcp/configure.ts)_
2572
2572
 
2573
2573
  ## `sanity media create-aspect`
2574
2574
 
@@ -2587,7 +2587,7 @@ EXAMPLES
2587
2587
  $ sanity media create-aspect
2588
2588
  ```
2589
2589
 
2590
- _See code: [src/commands/media/create-aspect.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/media/create-aspect.ts)_
2590
+ _See code: [src/commands/media/create-aspect.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/media/create-aspect.ts)_
2591
2591
 
2592
2592
  ## `sanity media delete-aspect ASPECTNAME`
2593
2593
 
@@ -2616,7 +2616,7 @@ EXAMPLES
2616
2616
  $ sanity media delete-aspect someAspect
2617
2617
  ```
2618
2618
 
2619
- _See code: [src/commands/media/delete-aspect.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/media/delete-aspect.ts)_
2619
+ _See code: [src/commands/media/delete-aspect.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/media/delete-aspect.ts)_
2620
2620
 
2621
2621
  ## `sanity media deploy-aspect [ASPECTNAME]`
2622
2622
 
@@ -2649,7 +2649,7 @@ EXAMPLES
2649
2649
  $ sanity media deploy-aspect --all
2650
2650
  ```
2651
2651
 
2652
- _See code: [src/commands/media/deploy-aspect.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/media/deploy-aspect.ts)_
2652
+ _See code: [src/commands/media/deploy-aspect.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/media/deploy-aspect.ts)_
2653
2653
 
2654
2654
  ## `sanity media export [DESTINATION]`
2655
2655
 
@@ -2690,7 +2690,7 @@ EXAMPLES
2690
2690
  $ sanity media export --media-library-id my-library-id
2691
2691
  ```
2692
2692
 
2693
- _See code: [src/commands/media/export.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/media/export.ts)_
2693
+ _See code: [src/commands/media/export.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/media/export.ts)_
2694
2694
 
2695
2695
  ## `sanity media import SOURCE`
2696
2696
 
@@ -2728,7 +2728,7 @@ EXAMPLES
2728
2728
  $ sanity media import products --replace-aspects
2729
2729
  ```
2730
2730
 
2731
- _See code: [src/commands/media/import.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/media/import.ts)_
2731
+ _See code: [src/commands/media/import.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/media/import.ts)_
2732
2732
 
2733
2733
  ## `sanity migration create [TITLE]`
2734
2734
 
@@ -2856,7 +2856,7 @@ EXAMPLES
2856
2856
  $ sanity openapi get query > query-api.yaml
2857
2857
  ```
2858
2858
 
2859
- _See code: [src/commands/openapi/get.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/openapi/get.ts)_
2859
+ _See code: [src/commands/openapi/get.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/openapi/get.ts)_
2860
2860
 
2861
2861
  ## `sanity openapi list`
2862
2862
 
@@ -2887,7 +2887,7 @@ EXAMPLES
2887
2887
  $ sanity openapi list --web
2888
2888
  ```
2889
2889
 
2890
- _See code: [src/commands/openapi/list.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/openapi/list.ts)_
2890
+ _See code: [src/commands/openapi/list.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/openapi/list.ts)_
2891
2891
 
2892
2892
  ## `sanity preview [OUTPUTDIR]`
2893
2893
 
@@ -2915,7 +2915,7 @@ EXAMPLES
2915
2915
  $ sanity preview some/build-output-dir
2916
2916
  ```
2917
2917
 
2918
- _See code: [src/commands/preview.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/preview.ts)_
2918
+ _See code: [src/commands/preview.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/preview.ts)_
2919
2919
 
2920
2920
  ## `sanity projects create [PROJECTNAME]`
2921
2921
 
@@ -2963,7 +2963,7 @@ EXAMPLES
2963
2963
  $ sanity projects create "CI Project" --yes --json
2964
2964
  ```
2965
2965
 
2966
- _See code: [src/commands/projects/create.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/projects/create.ts)_
2966
+ _See code: [src/commands/projects/create.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/projects/create.ts)_
2967
2967
 
2968
2968
  ## `sanity projects list`
2969
2969
 
@@ -2992,7 +2992,7 @@ EXAMPLES
2992
2992
  $ sanity projects list --sort=members --order=asc
2993
2993
  ```
2994
2994
 
2995
- _See code: [src/commands/projects/list.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/projects/list.ts)_
2995
+ _See code: [src/commands/projects/list.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/projects/list.ts)_
2996
2996
 
2997
2997
  ## `sanity schema delete`
2998
2998
 
@@ -3023,7 +3023,7 @@ EXAMPLES
3023
3023
  $ sanity schema delete --ids sanity.workspace.schema.workspaceName,prefix.sanity.workspace.schema.otherWorkspace
3024
3024
  ```
3025
3025
 
3026
- _See code: [src/commands/schema/delete.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/schema/delete.ts)_
3026
+ _See code: [src/commands/schema/delete.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/schema/delete.ts)_
3027
3027
 
3028
3028
  ## `sanity schema deploy`
3029
3029
 
@@ -3059,7 +3059,7 @@ EXAMPLES
3059
3059
  $ sanity schema deploy --workspace default
3060
3060
  ```
3061
3061
 
3062
- _See code: [src/commands/schema/deploy.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/schema/deploy.ts)_
3062
+ _See code: [src/commands/schema/deploy.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/schema/deploy.ts)_
3063
3063
 
3064
3064
  ## `sanity schema extract`
3065
3065
 
@@ -3098,7 +3098,7 @@ EXAMPLES
3098
3098
  $ sanity schema extract --watch --watch-patterns "lib/**/*.ts"
3099
3099
  ```
3100
3100
 
3101
- _See code: [src/commands/schema/extract.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/schema/extract.ts)_
3101
+ _See code: [src/commands/schema/extract.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/schema/extract.ts)_
3102
3102
 
3103
3103
  ## `sanity schema list`
3104
3104
 
@@ -3138,7 +3138,7 @@ EXAMPLES
3138
3138
  $ sanity schema list --json --id _.schemas.workspaceName
3139
3139
  ```
3140
3140
 
3141
- _See code: [src/commands/schema/list.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/schema/list.ts)_
3141
+ _See code: [src/commands/schema/list.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/schema/list.ts)_
3142
3142
 
3143
3143
  ## `sanity schema validate`
3144
3144
 
@@ -3181,7 +3181,7 @@ EXAMPLES
3181
3181
  $ sanity schema validate --debug-metafile-path metafile.json
3182
3182
  ```
3183
3183
 
3184
- _See code: [src/commands/schema/validate.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/schema/validate.ts)_
3184
+ _See code: [src/commands/schema/validate.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/schema/validate.ts)_
3185
3185
 
3186
3186
  ## `sanity telemetry disable`
3187
3187
 
@@ -3200,7 +3200,7 @@ EXAMPLES
3200
3200
  $ sanity telemetry telemetry disable
3201
3201
  ```
3202
3202
 
3203
- _See code: [src/commands/telemetry/disable.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/telemetry/disable.ts)_
3203
+ _See code: [src/commands/telemetry/disable.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/telemetry/disable.ts)_
3204
3204
 
3205
3205
  ## `sanity telemetry enable`
3206
3206
 
@@ -3219,7 +3219,7 @@ EXAMPLES
3219
3219
  $ sanity telemetry telemetry enable
3220
3220
  ```
3221
3221
 
3222
- _See code: [src/commands/telemetry/enable.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/telemetry/enable.ts)_
3222
+ _See code: [src/commands/telemetry/enable.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/telemetry/enable.ts)_
3223
3223
 
3224
3224
  ## `sanity telemetry status`
3225
3225
 
@@ -3238,7 +3238,7 @@ EXAMPLES
3238
3238
  $ sanity telemetry telemetry status
3239
3239
  ```
3240
3240
 
3241
- _See code: [src/commands/telemetry/status.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/telemetry/status.ts)_
3241
+ _See code: [src/commands/telemetry/status.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/telemetry/status.ts)_
3242
3242
 
3243
3243
  ## `sanity tokens add [LABEL]`
3244
3244
 
@@ -3284,7 +3284,7 @@ EXAMPLES
3284
3284
  $ sanity tokens add "My Token" --project-id abc123 --role=editor
3285
3285
  ```
3286
3286
 
3287
- _See code: [src/commands/tokens/add.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/tokens/add.ts)_
3287
+ _See code: [src/commands/tokens/add.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/tokens/add.ts)_
3288
3288
 
3289
3289
  ## `sanity tokens delete [TOKENID]`
3290
3290
 
@@ -3324,7 +3324,7 @@ EXAMPLES
3324
3324
  $ sanity tokens delete --project-id abc123
3325
3325
  ```
3326
3326
 
3327
- _See code: [src/commands/tokens/delete.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/tokens/delete.ts)_
3327
+ _See code: [src/commands/tokens/delete.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/tokens/delete.ts)_
3328
3328
 
3329
3329
  ## `sanity tokens list`
3330
3330
 
@@ -3357,7 +3357,7 @@ EXAMPLES
3357
3357
  $ sanity tokens list --project-id abc123
3358
3358
  ```
3359
3359
 
3360
- _See code: [src/commands/tokens/list.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/tokens/list.ts)_
3360
+ _See code: [src/commands/tokens/list.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/tokens/list.ts)_
3361
3361
 
3362
3362
  ## `sanity typegen generate`
3363
3363
 
@@ -3420,7 +3420,7 @@ DESCRIPTION
3420
3420
  Removes the deployed Sanity Studio/App from Sanity hosting
3421
3421
  ```
3422
3422
 
3423
- _See code: [src/commands/undeploy.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/undeploy.ts)_
3423
+ _See code: [src/commands/undeploy.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/undeploy.ts)_
3424
3424
 
3425
3425
  ## `sanity users invite [EMAIL]`
3426
3426
 
@@ -3460,7 +3460,7 @@ EXAMPLES
3460
3460
  $ sanity users invite pippi@sanity.io --project-id abc123
3461
3461
  ```
3462
3462
 
3463
- _See code: [src/commands/users/invite.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/users/invite.ts)_
3463
+ _See code: [src/commands/users/invite.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/users/invite.ts)_
3464
3464
 
3465
3465
  ## `sanity users list`
3466
3466
 
@@ -3502,7 +3502,7 @@ EXAMPLES
3502
3502
  $ sanity users list --project-id abc123
3503
3503
  ```
3504
3504
 
3505
- _See code: [src/commands/users/list.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/users/list.ts)_
3505
+ _See code: [src/commands/users/list.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/users/list.ts)_
3506
3506
 
3507
3507
  ## `sanity versions`
3508
3508
 
@@ -3519,6 +3519,6 @@ EXAMPLES
3519
3519
  $ sanity versions
3520
3520
  ```
3521
3521
 
3522
- _See code: [src/commands/versions.ts](https://github.com/sanity-io/cli/blob/v6.1.3/src/commands/versions.ts)_
3522
+ _See code: [src/commands/versions.ts](https://github.com/sanity-io/cli/blob/v6.1.4/src/commands/versions.ts)_
3523
3523
 
3524
3524
  <!-- commandsstop -->
@@ -8,7 +8,7 @@ export async function gatherDebugInfo(options) {
8
8
  const [auth, globalConfig, projectConfigResult, versions] = await Promise.all([
9
9
  gatherAuthInfo(includeSecrets),
10
10
  gatherGlobalConfig(),
11
- gatherProjectConfig(cliConfig),
11
+ cliConfig ? gatherProjectConfig(cliConfig) : undefined,
12
12
  gatherVersionsInfo(projectRoot)
13
13
  ]);
14
14
  // Gather user and project info that depend on auth
@@ -35,18 +35,16 @@ async function gatherAuthInfo(includeSecrets) {
35
35
  function gatherGlobalConfig() {
36
36
  return getUserConfig().all;
37
37
  }
38
- async function gatherProjectConfig(cliConfig) {
39
- try {
40
- const config = cliConfig;
41
- if (!config.api?.projectId) {
42
- return new Error('Missing required "api.projectId" key');
43
- }
44
- return config;
45
- } catch (error) {
46
- return error instanceof Error ? error : new Error('Failed to load project config');
38
+ function gatherProjectConfig(cliConfig) {
39
+ if (!cliConfig.api?.projectId) {
40
+ return new Error('Missing required "api.projectId" key');
47
41
  }
42
+ return cliConfig;
48
43
  }
49
44
  async function gatherVersionsInfo(projectRoot) {
45
+ if (!projectRoot) {
46
+ return undefined;
47
+ }
50
48
  try {
51
49
  return await findSanityModulesVersions({
52
50
  cwd: projectRoot.directory
@@ -63,7 +61,7 @@ async function gatherUserInfo(projectConfig, hasToken) {
63
61
  /**
64
62
  * If the project config has a project ID, get the user for the project
65
63
  * Otherwise, get the user for the global client
66
- */ const userInfo = projectConfig instanceof Error || !projectConfig.api?.projectId ? await getCliUser() : await getProjectUser(projectConfig.api.projectId);
64
+ */ const userInfo = !projectConfig || projectConfig instanceof Error || !projectConfig.api?.projectId ? await getCliUser() : await getProjectUser(projectConfig.api.projectId);
67
65
  return {
68
66
  email: userInfo.email,
69
67
  id: userInfo.id,
@@ -74,7 +72,7 @@ async function gatherUserInfo(projectConfig, hasToken) {
74
72
  }
75
73
  }
76
74
  async function gatherProjectInfo(projectConfig, hasToken, user) {
77
- if (!hasToken || projectConfig instanceof Error) {
75
+ if (!hasToken || !projectConfig || projectConfig instanceof Error) {
78
76
  return null;
79
77
  }
80
78
  const projectId = projectConfig.api?.projectId;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/debug/gatherDebugInfo.ts"],"sourcesContent":["import {type CliConfig, getCliToken, getUserConfig, type ProjectRootResult} from '@sanity/cli-core'\n\nimport {getProjectById} from '../../services/projects.js'\nimport {getCliUser, getProjectUser} from '../../services/user.js'\nimport {findSanityModulesVersions} from '../versions/findSanityModulesVersions.js'\nimport {type ModuleVersionResult} from '../versions/types.js'\nimport {\n type AuthInfo,\n type DebugInfo,\n type DebugInfoOptions,\n type ProjectInfo,\n type UserInfo,\n} from './types.js'\n\nexport async function gatherDebugInfo(options: DebugInfoOptions): Promise<DebugInfo> {\n const {cliConfig, includeSecrets, projectRoot} = options\n\n // Gather all info in parallel where possible\n const [auth, globalConfig, projectConfigResult, versions] = await Promise.all([\n gatherAuthInfo(includeSecrets),\n gatherGlobalConfig(),\n gatherProjectConfig(cliConfig),\n gatherVersionsInfo(projectRoot),\n ])\n\n // Gather user and project info that depend on auth\n const user = await gatherUserInfo(projectConfigResult, auth.hasToken)\n const project = await gatherProjectInfo(projectConfigResult, auth.hasToken, user)\n\n return {\n auth,\n globalConfig,\n project,\n projectConfig: projectConfigResult,\n user,\n versions,\n }\n}\n\nasync function gatherAuthInfo(includeSecrets: boolean): Promise<AuthInfo> {\n const token = await getCliToken()\n const hasToken = Boolean(token)\n\n return {\n authToken: includeSecrets && token ? token : '<redacted>',\n hasToken,\n userType: 'normal',\n }\n}\n\nfunction gatherGlobalConfig(): Record<string, unknown> {\n return getUserConfig().all\n}\n\nasync function gatherProjectConfig(cliConfig: CliConfig): Promise<CliConfig | Error> {\n try {\n const config = cliConfig\n\n if (!config.api?.projectId) {\n return new Error('Missing required \"api.projectId\" key')\n }\n\n return config\n } catch (error) {\n return error instanceof Error ? error : new Error('Failed to load project config')\n }\n}\n\nasync function gatherVersionsInfo(projectRoot: ProjectRootResult): Promise<ModuleVersionResult[]> {\n try {\n return await findSanityModulesVersions({cwd: projectRoot.directory})\n } catch {\n return []\n }\n}\n\nasync function gatherUserInfo(\n projectConfig: CliConfig | Error,\n hasToken: boolean,\n): Promise<Error | UserInfo | null> {\n if (!hasToken) {\n return new Error('Not logged in')\n }\n\n try {\n /**\n * If the project config has a project ID, get the user for the project\n * Otherwise, get the user for the global client\n */\n const userInfo =\n projectConfig instanceof Error || !projectConfig.api?.projectId\n ? await getCliUser()\n : await getProjectUser(projectConfig.api.projectId)\n\n return {\n email: userInfo.email,\n id: userInfo.id,\n name: userInfo.name,\n }\n } catch (error) {\n return error instanceof Error ? error : new Error('Failed to fetch user info')\n }\n}\n\nasync function gatherProjectInfo(\n projectConfig: CliConfig | Error,\n hasToken: boolean,\n user: Error | UserInfo | null,\n): Promise<Error | ProjectInfo | null> {\n if (!hasToken || projectConfig instanceof Error) {\n return null\n }\n\n const projectId = projectConfig.api?.projectId\n if (!projectId) {\n return null\n }\n\n try {\n const projectInfo = await getProjectById(projectId)\n\n if (!projectInfo) {\n return new Error(`Project specified in configuration (${projectId}) does not exist in API`)\n }\n\n const userId = user instanceof Error || !user ? null : user.id\n const member = (projectInfo.members || []).find((member) => member.id === userId)\n\n return {\n displayName: projectInfo.displayName,\n id: projectId,\n // @ts-expect-error - Incorrect type definition in @sanity/client\n userRoles: member && member.roles ? member.roles.map((role) => role.name) : ['<none>'],\n }\n } catch (error) {\n return error instanceof Error ? error : new Error('Failed to fetch project info')\n }\n}\n"],"names":["getCliToken","getUserConfig","getProjectById","getCliUser","getProjectUser","findSanityModulesVersions","gatherDebugInfo","options","cliConfig","includeSecrets","projectRoot","auth","globalConfig","projectConfigResult","versions","Promise","all","gatherAuthInfo","gatherGlobalConfig","gatherProjectConfig","gatherVersionsInfo","user","gatherUserInfo","hasToken","project","gatherProjectInfo","projectConfig","token","Boolean","authToken","userType","config","api","projectId","Error","error","cwd","directory","userInfo","email","id","name","projectInfo","userId","member","members","find","displayName","userRoles","roles","map","role"],"mappings":"AAAA,SAAwBA,WAAW,EAAEC,aAAa,QAA+B,mBAAkB;AAEnG,SAAQC,cAAc,QAAO,6BAA4B;AACzD,SAAQC,UAAU,EAAEC,cAAc,QAAO,yBAAwB;AACjE,SAAQC,yBAAyB,QAAO,2CAA0C;AAUlF,OAAO,eAAeC,gBAAgBC,OAAyB;IAC7D,MAAM,EAACC,SAAS,EAAEC,cAAc,EAAEC,WAAW,EAAC,GAAGH;IAEjD,6CAA6C;IAC7C,MAAM,CAACI,MAAMC,cAAcC,qBAAqBC,SAAS,GAAG,MAAMC,QAAQC,GAAG,CAAC;QAC5EC,eAAeR;QACfS;QACAC,oBAAoBX;QACpBY,mBAAmBV;KACpB;IAED,mDAAmD;IACnD,MAAMW,OAAO,MAAMC,eAAeT,qBAAqBF,KAAKY,QAAQ;IACpE,MAAMC,UAAU,MAAMC,kBAAkBZ,qBAAqBF,KAAKY,QAAQ,EAAEF;IAE5E,OAAO;QACLV;QACAC;QACAY;QACAE,eAAeb;QACfQ;QACAP;IACF;AACF;AAEA,eAAeG,eAAeR,cAAuB;IACnD,MAAMkB,QAAQ,MAAM3B;IACpB,MAAMuB,WAAWK,QAAQD;IAEzB,OAAO;QACLE,WAAWpB,kBAAkBkB,QAAQA,QAAQ;QAC7CJ;QACAO,UAAU;IACZ;AACF;AAEA,SAASZ;IACP,OAAOjB,gBAAgBe,GAAG;AAC5B;AAEA,eAAeG,oBAAoBX,SAAoB;IACrD,IAAI;QACF,MAAMuB,SAASvB;QAEf,IAAI,CAACuB,OAAOC,GAAG,EAAEC,WAAW;YAC1B,OAAO,IAAIC,MAAM;QACnB;QAEA,OAAOH;IACT,EAAE,OAAOI,OAAO;QACd,OAAOA,iBAAiBD,QAAQC,QAAQ,IAAID,MAAM;IACpD;AACF;AAEA,eAAed,mBAAmBV,WAA8B;IAC9D,IAAI;QACF,OAAO,MAAML,0BAA0B;Y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EAAE,OAAON,OAAO;QACd,OAAOA,iBAAiBD,QAAQC,QAAQ,IAAID,MAAM;IACpD;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/debug/gatherDebugInfo.ts"],"sourcesContent":["import {type CliConfig, getCliToken, getUserConfig, type ProjectRootResult} from '@sanity/cli-core'\n\nimport {getProjectById} from '../../services/projects.js'\nimport {getCliUser, getProjectUser} from '../../services/user.js'\nimport {findSanityModulesVersions} from '../versions/findSanityModulesVersions.js'\nimport {type ModuleVersionResult} from '../versions/types.js'\nimport {\n type AuthInfo,\n type DebugInfo,\n type DebugInfoOptions,\n type ProjectInfo,\n type UserInfo,\n} from './types.js'\n\nexport async function gatherDebugInfo(options: DebugInfoOptions): Promise<DebugInfo> {\n const {cliConfig, includeSecrets, projectRoot} = options\n\n // Gather all info in parallel where possible\n const [auth, globalConfig, projectConfigResult, versions] = await Promise.all([\n gatherAuthInfo(includeSecrets),\n gatherGlobalConfig(),\n cliConfig ? gatherProjectConfig(cliConfig) : undefined,\n gatherVersionsInfo(projectRoot),\n ])\n\n // Gather user and project info that depend on auth\n const user = await gatherUserInfo(projectConfigResult, auth.hasToken)\n const project = await gatherProjectInfo(projectConfigResult, auth.hasToken, user)\n\n return {\n auth,\n globalConfig,\n project,\n projectConfig: projectConfigResult,\n user,\n versions,\n }\n}\n\nasync function gatherAuthInfo(includeSecrets: boolean): Promise<AuthInfo> {\n const token = await getCliToken()\n const hasToken = Boolean(token)\n\n return {\n authToken: includeSecrets && token ? token : '<redacted>',\n hasToken,\n userType: 'normal',\n }\n}\n\nfunction gatherGlobalConfig(): Record<string, unknown> {\n return getUserConfig().all\n}\n\nfunction gatherProjectConfig(cliConfig: CliConfig): CliConfig | Error {\n if (!cliConfig.api?.projectId) {\n return new Error('Missing required \"api.projectId\" key')\n }\n\n return cliConfig\n}\n\nasync function gatherVersionsInfo(\n projectRoot: ProjectRootResult | undefined,\n): Promise<ModuleVersionResult[] | undefined> {\n if (!projectRoot) {\n return undefined\n }\n\n try {\n return await findSanityModulesVersions({cwd: projectRoot.directory})\n } catch {\n return []\n }\n}\n\nasync function gatherUserInfo(\n projectConfig: CliConfig | Error | undefined,\n hasToken: boolean,\n): Promise<Error | UserInfo | null> {\n if (!hasToken) {\n return new Error('Not logged in')\n }\n\n try {\n /**\n * If the project config has a project ID, get the user for the project\n * Otherwise, get the user for the global client\n */\n const userInfo =\n !projectConfig || projectConfig instanceof Error || !projectConfig.api?.projectId\n ? await getCliUser()\n : await getProjectUser(projectConfig.api.projectId)\n\n return {\n email: userInfo.email,\n id: userInfo.id,\n name: userInfo.name,\n }\n } catch (error) {\n return error instanceof Error ? error : new Error('Failed to fetch user info')\n }\n}\n\nasync function gatherProjectInfo(\n projectConfig: CliConfig | Error | undefined,\n hasToken: boolean,\n user: Error | UserInfo | null,\n): Promise<Error | ProjectInfo | null> {\n if (!hasToken || !projectConfig || projectConfig instanceof Error) {\n return null\n }\n\n const projectId = projectConfig.api?.projectId\n if (!projectId) {\n return null\n }\n\n try {\n const projectInfo = await getProjectById(projectId)\n\n if (!projectInfo) {\n return new Error(`Project specified in configuration (${projectId}) does not exist in API`)\n }\n\n const userId = user instanceof Error || !user ? null : user.id\n const member = (projectInfo.members || []).find((member) => member.id === userId)\n\n return {\n displayName: projectInfo.displayName,\n id: projectId,\n // @ts-expect-error - Incorrect type definition in @sanity/client\n userRoles: member && member.roles ? member.roles.map((role) => role.name) : ['<none>'],\n }\n } catch (error) {\n return error instanceof Error ? error : new Error('Failed to fetch project info')\n }\n}\n"],"names":["getCliToken","getUserConfig","getProjectById","getCliUser","getProjectUser","findSanityModulesVersions","gatherDebugInfo","options","cliConfig","includeSecrets","projectRoot","auth","globalConfig","projectConfigResult","versions","Promise","all","gatherAuthInfo","gatherGlobalConfig","gatherProjectConfig","undefined","gatherVersionsInfo","user","gatherUserInfo","hasToken","project","gatherProjectInfo","projectConfig","token","Boolean","authToken","userType","api","projectId","Error","cwd","directory","userInfo","email","id","name","error","projectInfo","userId","member","members","find","displ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ACpD;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/debug/types.ts"],"sourcesContent":["import {type CliConfig, type ProjectRootResult} from '@sanity/cli-core'\n\nimport {type ModuleVersionResult} from '../versions/types.js'\n\nexport interface DebugInfoOptions {\n cliConfig: CliConfig\n includeSecrets: boolean\n projectRoot: ProjectRootResult\n}\n\nexport interface UserInfo {\n email: string\n id: string\n name: string\n}\n\nexport interface ProjectInfo {\n displayName: string\n id: string\n userRoles: string[]\n}\n\nexport interface AuthInfo {\n authToken: string\n hasToken: boolean\n userType: string\n}\n\nexport interface DebugInfo {\n auth: AuthInfo\n globalConfig: Record<string, unknown>\n project: Error | ProjectInfo | null\n projectConfig: CliConfig | Error\n user: Error | UserInfo | null\n versions: ModuleVersionResult[]\n}\n"],"names":[],"mappings":"AA4BA,WAOC"}
1
+ {"version":3,"sources":["../../../src/actions/debug/types.ts"],"sourcesContent":["import {type CliConfig, type ProjectRootResult} from '@sanity/cli-core'\n\nimport {type ModuleVersionResult} from '../versions/types.js'\n\nexport interface DebugInfoOptions {\n cliConfig: CliConfig | undefined\n includeSecrets: boolean\n projectRoot: ProjectRootResult | undefined\n}\n\nexport interface UserInfo {\n email: string\n id: string\n name: string\n}\n\nexport interface ProjectInfo {\n displayName: string\n id: string\n userRoles: string[]\n}\n\nexport interface AuthInfo {\n authToken: string\n hasToken: boolean\n userType: string\n}\n\nexport interface DebugInfo {\n auth: AuthInfo\n globalConfig: Record<string, unknown>\n project: Error | ProjectInfo | null\n projectConfig: CliConfig | Error | undefined\n user: Error | UserInfo | null\n versions: ModuleVersionResult[] | undefined\n}\n"],"names":[],"mappings":"AA4BA,WAOC"}
@@ -19,12 +19,23 @@ async function main() {
19
19
  if (workspaces.length === 0) {
20
20
  throw new Error('No workspaces found');
21
21
  }
22
+ // Extract manifest data (including ManifestSchemaType[]) once, while Schema objects are
23
+ // still live. Both writeWorkspaceToDist and updateWorkspacesSchemas consume the result.
24
+ const workspaceManifests = await extractWorkspaceManifest(workspaces, workDir);
25
+ const schemaInputs = workspaceManifests.map((manifest)=>({
26
+ dataset: manifest.dataset,
27
+ manifestSchema: manifest.schema,
28
+ name: manifest.name,
29
+ projectId: manifest.projectId,
30
+ title: manifest.title
31
+ }));
22
32
  debug('Handling deployment for %s', isExternal ? 'external' : 'internal');
23
33
  let studioManifest = null;
24
34
  if (isExternal) {
25
35
  ;
26
36
  [studioManifest] = await handleExternalDeployment({
27
37
  projectId,
38
+ schemaInputs,
28
39
  schemaRequired,
29
40
  verbose,
30
41
  workDir,
@@ -35,8 +46,10 @@ async function main() {
35
46
  [studioManifest] = await handleInternalDeployment({
36
47
  outPath,
37
48
  projectId,
49
+ schemaInputs,
38
50
  verbose,
39
51
  workDir,
52
+ workspaceManifests,
40
53
  workspaces
41
54
  });
42
55
  }
@@ -54,20 +67,11 @@ async function main() {
54
67
  });
55
68
  }
56
69
  }
57
- async function writeWorkspaceToDist({ outPath, workDir, workspaces }) {
58
- // Get the create manifest workspace
59
- const workspaceManifests = await extractWorkspaceManifest(workspaces, workDir);
60
- await writeManifestFile({
61
- outPath,
62
- workDir,
63
- workspaceManifests
64
- });
65
- }
66
70
  /**
67
71
  * External deployments:
68
72
  * 1. Update the workspace schemas to the /schemas endpoint IF --schema-required is passed
69
73
  * 2. Update server-side schemas
70
- */ async function handleExternalDeployment({ projectId, schemaRequired, verbose, workDir, workspaces }) {
74
+ */ async function handleExternalDeployment({ projectId, schemaInputs, schemaRequired, verbose, workDir, workspaces }) {
71
75
  const [studioManifest] = await Promise.all([
72
76
  uploadSchemaToLexicon({
73
77
  projectId,
@@ -77,7 +81,7 @@ async function writeWorkspaceToDist({ outPath, workDir, workspaces }) {
77
81
  }),
78
82
  schemaRequired ? updateWorkspacesSchemas({
79
83
  verbose,
80
- workspaces
84
+ workspaces: schemaInputs
81
85
  }) : undefined
82
86
  ]);
83
87
  return [
@@ -92,7 +96,7 @@ async function writeWorkspaceToDist({ outPath, workDir, workspaces }) {
92
96
  * 3. Update server-side schemas
93
97
  *
94
98
  * @param workspaces - The workspaces to deploy
95
- */ async function handleInternalDeployment({ outPath, projectId, verbose, workDir, workspaces }) {
99
+ */ async function handleInternalDeployment({ outPath, projectId, schemaInputs, verbose, workDir, workspaceManifests, workspaces }) {
96
100
  const [studioManifest] = await Promise.all([
97
101
  uploadSchemaToLexicon({
98
102
  projectId,
@@ -100,15 +104,15 @@ async function writeWorkspaceToDist({ outPath, workDir, workspaces }) {
100
104
  workDir,
101
105
  workspaces
102
106
  }),
103
- writeWorkspaceToDist({
107
+ writeManifestFile({
104
108
  outPath,
105
109
  workDir,
106
- workspaces
110
+ workspaceManifests
107
111
  }),
108
112
  // Updates the workspaces schemas to /schemas endpoint
109
113
  updateWorkspacesSchemas({
110
114
  verbose,
111
- workspaces
115
+ workspaces: schemaInputs
112
116
  })
113
117
  ]);
114
118
  return [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/deploy/deployStudioSchemasAndManifests.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {getStudioWorkspaces, subdebug} from '@sanity/cli-core'\nimport {type StudioManifest, type Workspace} from 'sanity'\n\nimport {extractWorkspaceManifest} from '../manifest/extractWorkspaceManifest.js'\nimport {writeManifestFile} from '../manifest/writeManifestFile.js'\nimport {updateWorkspacesSchemas} from '../schema/updateWorkspaceSchema.js'\nimport {uploadSchemaToLexicon} from '../schema/uploadSchemaToLexicon.js'\nimport {extractValidationFromSchemaError} from '../schema/utils/extractValidationFromSchemaError.js'\nimport {deployStudioSchemasAndManifestsWorkerData} from './types.js'\n\nconst debug = subdebug('deployStudioSchemasAndManifests.worker')\n\nasync function main() {\n if (isMainThread || !parentPort) {\n throw new Error('Should only be run in a worker!')\n }\n\n const {configPath, isExternal, outPath, projectId, schemaRequired, verbose, workDir} =\n deployStudioSchemasAndManifestsWorkerData.parse(workerData)\n\n try {\n debug('Deploying studio schemas and manifests from config path %s', configPath)\n const workspaces = await getStudioWorkspaces(configPath)\n debug('Workspaces %o', workspaces)\n\n if (workspaces.length === 0) {\n throw new Error('No workspaces found')\n }\n\n debug('Handling deployment for %s', isExternal ? 'external' : 'internal')\n\n let studioManifest: StudioManifest | null = null\n\n if (isExternal) {\n ;[studioManifest] = await handleExternalDeployment({\n projectId,\n schemaRequired,\n verbose,\n workDir,\n workspaces,\n })\n } else {\n ;[studioManifest] = await handleInternalDeployment({\n outPath,\n projectId,\n verbose,\n workDir,\n workspaces,\n })\n }\n\n parentPort.postMessage({\n studioManifest,\n type: 'success',\n })\n } catch (error) {\n debug('Error deploying studio schemas and manifests', error)\n const validation = await extractValidationFromSchemaError(error, workDir)\n parentPort.postMessage({\n error: error instanceof Error ? error.message : String(error),\n type: 'error',\n validation,\n })\n }\n}\n\nasync function writeWorkspaceToDist({\n outPath,\n workDir,\n workspaces,\n}: {\n outPath: string\n workDir: string\n workspaces: Workspace[]\n}) {\n // Get the create manifest workspace\n const workspaceManifests = await extractWorkspaceManifest(workspaces, workDir)\n\n await writeManifestFile({\n outPath,\n workDir,\n workspaceManifests,\n })\n}\n\n/**\n * External deployments:\n * 1. Update the workspace schemas to the /schemas endpoint IF --schema-required is passed\n * 2. Update server-side schemas\n */\nasync function handleExternalDeployment({\n projectId,\n schemaRequired,\n verbose,\n workDir,\n workspaces,\n}: {\n projectId: string\n schemaRequired: boolean\n verbose: boolean\n workDir: string\n workspaces: Workspace[]\n}): Promise<[StudioManifest | null]> {\n const [studioManifest] = await Promise.all([\n uploadSchemaToLexicon({\n projectId,\n verbose,\n workDir,\n workspaces,\n }),\n schemaRequired ? updateWorkspacesSchemas({verbose, workspaces}) : undefined,\n ])\n\n return [studioManifest]\n}\n\n/**\n *\n * Internal deployments:\n * 1. Write the workspace manifests to the dist directory\n * 2. Update the workspaces schemas to the /schemas endpoint\n * 3. Update server-side schemas\n *\n * @param workspaces - The workspaces to deploy\n */\nasync function handleInternalDeployment({\n outPath,\n projectId,\n verbose,\n workDir,\n workspaces,\n}: {\n outPath: string\n projectId: string\n verbose: boolean\n workDir: string\n workspaces: Workspace[]\n}): Promise<[StudioManifest | null]> {\n const [studioManifest] = await Promise.all([\n uploadSchemaToLexicon({\n projectId,\n verbose,\n workDir,\n workspaces,\n }),\n writeWorkspaceToDist({outPath, workDir, workspaces}),\n // Updates the workspaces schemas to /schemas endpoint\n updateWorkspacesSchemas({\n verbose,\n workspaces,\n }),\n ])\n\n return [studioManifest]\n}\n\nawait main()\n"],"names":["isMainThread","parentPort","workerData","getStudioWorkspaces","subdebug","extractWorkspaceManifest","writeManifestFile","updateWorkspacesSchemas","uploadSchemaToLexicon","extractValidationFromSchemaError","deployStudioSchemasAndManifestsWorkerData","debug","main","Error","configPath","isExternal","outPath","projectId","schemaRequired","verbose","workDir","parse","workspaces","length","studioManifest","handleExternalDeployment","handleInternalDeployment","postMessage","type","error","validation","message","String","writeWorkspaceToDist","workspaceManifests","Promise","all","undefined"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,mBAAmB,EAAEC,QAAQ,QAAO,mBAAkB;AAG9D,SAAQC,wBAAwB,QAAO,0CAAyC;AAChF,SAAQC,iBAAiB,QAAO,mCAAkC;AAClE,SAAQC,uBAAuB,QAAO,qCAAoC;AAC1E,SAAQC,qBAAqB,QAAO,qCAAoC;AACxE,SAAQC,gCAAgC,QAAO,sDAAqD;AACpG,SAAQC,yCAAyC,QAAO,aAAY;AAEpE,MAAMC,QAAQP,SAAS;AAEvB,eAAeQ;IACb,IAAIZ,gBAAgB,CAACC,YAAY;QAC/B,MAAM,IAAIY,MAAM;IAClB;IAEA,MAAM,EAACC,UAAU,EAAEC,UAAU,EAAEC,OAAO,EAAEC,SAAS,EAAEC,cAAc,EAAEC,OAAO,EAAEC,OAAO,EAAC,GAClFV,0CAA0CW,KAAK,CAACnB;IAElD,IAAI;QACFS,MAAM,8DAA8DG;QACpE,MAAMQ,aAAa,MAAMnB,oBAAoBW;QAC7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QAAQC,GAAG,CAAC;QACzC5B,sBAAsB;YACpBS;YACAE;YACAC;YACAE;QACF;QACAW,qBAAqB;YAACjB;YAASI;YAASE;QAAU;QAClD,sDAAsD;QACtDf,wBAAwB;YACtBY;YACAG;QACF;KACD;IAED,OAAO;QAACE;KAAe;AACzB;AAEA,MAAMZ"}
1
+ {"version":3,"sources":["../../../src/actions/deploy/deployStudioSchemasAndManifests.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {getStudioWorkspaces, subdebug} from '@sanity/cli-core'\nimport {type StudioManifest, type Workspace} from 'sanity'\n\nimport {extractWorkspaceManifest} from '../manifest/extractWorkspaceManifest.js'\nimport {type CreateWorkspaceManifest} from '../manifest/types.js'\nimport {writeManifestFile} from '../manifest/writeManifestFile.js'\nimport {\n updateWorkspacesSchemas,\n type WorkspaceSchemaInput,\n} from '../schema/updateWorkspaceSchema.js'\nimport {uploadSchemaToLexicon} from '../schema/uploadSchemaToLexicon.js'\nimport {extractValidationFromSchemaError} from '../schema/utils/extractValidationFromSchemaError.js'\nimport {deployStudioSchemasAndManifestsWorkerData} from './types.js'\n\nconst debug = subdebug('deployStudioSchemasAndManifests.worker')\n\nasync function main() {\n if (isMainThread || !parentPort) {\n throw new Error('Should only be run in a worker!')\n }\n\n const {configPath, isExternal, outPath, projectId, schemaRequired, verbose, workDir} =\n deployStudioSchemasAndManifestsWorkerData.parse(workerData)\n\n try {\n debug('Deploying studio schemas and manifests from config path %s', configPath)\n const workspaces = await getStudioWorkspaces(configPath)\n debug('Workspaces %o', workspaces)\n\n if (workspaces.length === 0) {\n throw new Error('No workspaces found')\n }\n\n // Extract manifest data (including ManifestSchemaType[]) once, while Schema objects are\n // still live. Both writeWorkspaceToDist and updateWorkspacesSchemas consume the result.\n const workspaceManifests = await extractWorkspaceManifest(workspaces, workDir)\n\n const schemaInputs: WorkspaceSchemaInput[] = workspaceManifests.map((manifest) => ({\n dataset: manifest.dataset,\n manifestSchema: manifest.schema,\n name: manifest.name,\n projectId: manifest.projectId,\n title: manifest.title,\n }))\n\n debug('Handling deployment for %s', isExternal ? 'external' : 'internal')\n\n let studioManifest: StudioManifest | null = null\n\n if (isExternal) {\n ;[studioManifest] = await handleExternalDeployment({\n projectId,\n schemaInputs,\n schemaRequired,\n verbose,\n workDir,\n workspaces,\n })\n } else {\n ;[studioManifest] = await handleInternalDeployment({\n outPath,\n projectId,\n schemaInputs,\n verbose,\n workDir,\n workspaceManifests,\n workspaces,\n })\n }\n\n parentPort.postMessage({\n studioManifest,\n type: 'success',\n })\n } catch (error) {\n debug('Error deploying studio schemas and manifests', error)\n const validation = await extractValidationFromSchemaError(error, workDir)\n parentPort.postMessage({\n error: error instanceof Error ? error.message : String(error),\n type: 'error',\n validation,\n })\n }\n}\n\n/**\n * External deployments:\n * 1. Update the workspace schemas to the /schemas endpoint IF --schema-required is passed\n * 2. Update server-side schemas\n */\nasync function handleExternalDeployment({\n projectId,\n schemaInputs,\n schemaRequired,\n verbose,\n workDir,\n workspaces,\n}: {\n projectId: string\n schemaInputs: WorkspaceSchemaInput[]\n schemaRequired: boolean\n verbose: boolean\n workDir: string\n workspaces: Workspace[]\n}): Promise<[StudioManifest | null]> {\n const [studioManifest] = await Promise.all([\n uploadSchemaToLexicon({\n projectId,\n verbose,\n workDir,\n workspaces,\n }),\n schemaRequired ? updateWorkspacesSchemas({verbose, workspaces: schemaInputs}) : undefined,\n ])\n\n return [studioManifest]\n}\n\n/**\n *\n * Internal deployments:\n * 1. Write the workspace manifests to the dist directory\n * 2. Update the workspaces schemas to the /schemas endpoint\n * 3. Update server-side schemas\n *\n * @param workspaces - The workspaces to deploy\n */\nasync function handleInternalDeployment({\n outPath,\n projectId,\n schemaInputs,\n verbose,\n workDir,\n workspaceManifests,\n workspaces,\n}: {\n outPath: string\n projectId: string\n schemaInputs: WorkspaceSchemaInput[]\n verbose: boolean\n workDir: string\n workspaceManifests: CreateWorkspaceManifest[]\n workspaces: Workspace[]\n}): Promise<[StudioManifest | null]> {\n const [studioManifest] = await Promise.all([\n uploadSchemaToLexicon({\n projectId,\n verbose,\n workDir,\n workspaces,\n }),\n writeManifestFile({outPath, workDir, workspaceManifests}),\n // Updates the workspaces schemas to /schemas endpoint\n updateWorkspacesSchemas({\n verbose,\n workspaces: schemaInputs,\n }),\n ])\n\n return [studioManifest]\n}\n\nawait main()\n"],"names":["isMainThread","parentPort","workerData","getStudioWorkspaces","subdebug","extractWorkspaceManifest","writeManifestFile","updateWorkspacesSchemas","uploadSchemaToLexicon","extractValidationFromSchemaError","deployStudioSchemasAndManifestsWorkerData","debug","main","Error","configPath","isExternal","outPath","projectId","schemaRequired","verbose","workDir","parse","workspaces","length","workspaceManifests","schemaInputs","map","manifest","dataset","manifestSchema","schema","name","title","studioManifest","handleExternalDeployment","handleInternalDeployment","postMessage","type","error","validation","message","String","Promise","all","undefined"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,mBAAmB,EAAEC,QAAQ,QAAO,mBAAkB;AAG9D,SAAQC,wBAAwB,QAAO,0CAAyC;AAEhF,SAAQC,iBAAiB,QAAO,mCAAkC;AAClE,SACEC,uBAAuB,QAElB,qCAAoC;AAC3C,SAAQC,qBAAqB,QAAO,qCAAoC;AACxE,SAAQC,gCAAgC,QAAO,sDAAqD;AACpG,SAAQC,yCAAyC,QAAO,aAAY;AAEpE,MAAMC,QAAQP,SAAS;AAEvB,eAAeQ;IACb,IAAIZ,gBAAgB,CAACC,YAAY;QAC/B,MAAM,IAAIY,MAAM;IAClB;IAEA,MAAM,EAACC,UAAU,EAAEC,UAAU,EAAEC,OAAO,EAAEC,SAAS,EAAEC,cAAc,EAAEC,OAAO,EAAEC,OAAO,EAAC,GAClFV,0CAA0CW,KAAK,CAACnB;IAElD,IAAI;QACFS,MAAM,8DAA8DG;QACpE,MAAMQ,aAAa,MAAMnB,oBAAoBW;QAC7CH,MAAM,iBAAiBW;QAEvB,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AEA;;;;;;;;CAQC,GACD,eAAeE,yBAAyB,EACtCnB,OAAO,EACPC,SAAS,EACTQ,YAAY,EACZN,OAAO,EACPC,OAAO,EACPI,kBAAkB,EAClBF,UAAU,EASX;IACC,MAAM,CAACW,eAAe,GAAG,MAAMS,QAAQC,GAAG,CAAC;QACzCnC,sBAAsB;YACpBS;YACAE;YACAC;YACAE;QACF;QACAhB,kBAAkB;YAACU;YAASI;YAASI;QAAkB;QACvD,sDAAsD;QACtDjB,wBAAwB;YACtBY;YACAG,YAAYG;QACd;KACD;IAED,OAAO;QAACQ;KAAe;AACzB;AAEA,MAAMrB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/manifest/types.ts"],"sourcesContent":["import {type SanityDocumentLike} from '@sanity/types'\nimport {type MediaLibraryConfig, type Workspace} from 'sanity'\nimport {z} from 'zod'\n\nexport const SANITY_WORKSPACE_SCHEMA_ID_PREFIX = '_.schemas'\nexport const SANITY_WORKSPACE_SCHEMA_TYPE = 'system.schema'\nexport const CURRENT_WORKSPACE_SCHEMA_VERSION = '2025-05-01'\n\nexport type ManifestSerializable =\n | boolean\n | ManifestSerializable[]\n | number\n | string\n | {[k: string]: ManifestSerializable}\n\nexport interface CreateManifest {\n createdAt: string\n studioVersion: string | null\n version: number\n workspaces: ManifestWorkspaceFile[]\n}\n\nexport interface AppManifest {\n version: '1'\n\n icon?: string\n title?: string\n}\n\nexport interface ManifestWorkspaceFile extends Omit<CreateWorkspaceManifest, 'schema' | 'tools'> {\n schema: string // filename\n tools: string // filename\n}\n\nexport interface CreateWorkspaceManifest {\n basePath: string\n dataset: string\n /**\n * returns null in the case of the icon not being able to be stringified\n */\n icon: string | null\n name: string\n projectId: string\n schema: ManifestSchemaType[]\n tools: ManifestTool[]\n\n mediaLibrary?: MediaLibraryConfig\n subtitle?: string\n title?: string\n}\n\nexport interface ManifestSchemaType {\n name: string\n type: string\n\n deprecated?: {\n reason: string\n }\n fields?: ManifestField[]\n fieldsets?: ManifestFieldset[]\n hidden?: 'conditional' | boolean\n lists?: ManifestTitledValue[]\n //portable text\n marks?: {\n annotations?: ManifestArrayMember[]\n decorators?: ManifestTitledValue[]\n }\n of?: ManifestArrayMember[]\n options?: Record<string, ManifestSerializable>\n preview?: {\n select: Record<string, string>\n }\n readOnly?: 'conditional' | boolean\n styles?: ManifestTitledValue[]\n title?: string\n to?: ManifestReferenceMember[]\n validation?: ManifestValidationGroup[]\n\n // userland (assignable to ManifestSerializable | undefined)\n // not included to add some typesafty to extractManifest\n // [index: string]: unknown\n}\n\nexport interface ManifestFieldset {\n [index: string]: ManifestSerializable | undefined\n name: string\n\n title?: string\n}\n\nexport interface ManifestTitledValue {\n value: string\n\n title?: string\n}\n\ntype ManifestArrayMember = Omit<ManifestSchemaType, 'name'> & {name?: string}\ntype ManifestReferenceMember = Omit<ManifestSchemaType, 'name'> & {name?: string}\nexport type ManifestField = ManifestSchemaType & {fieldset?: string}\n\nexport interface ManifestValidationGroup {\n rules: ManifestValidationRule[]\n\n level?: 'error' | 'info' | 'warning'\n message?: string\n}\n\nexport type ManifestValidationRule = {\n [index: string]: ManifestSerializable | undefined\n constraint?: ManifestSerializable\n flag: string\n}\n\nexport interface ManifestTool {\n /**\n * returns null in the case of the icon not being able to be stringified\n */\n icon: string | null\n name: string\n title: string\n type: string | null\n}\n\nexport type DefaultWorkspaceSchemaId = `${typeof SANITY_WORKSPACE_SCHEMA_ID_PREFIX}.${string}`\ntype PrefixedWorkspaceSchemaId = `${DefaultWorkspaceSchemaId}.${string}`\nexport type WorkspaceSchemaId = DefaultWorkspaceSchemaId | PrefixedWorkspaceSchemaId\n\nexport interface StoredWorkspaceSchema extends SanityDocumentLike {\n _id: WorkspaceSchemaId\n _type: typeof SANITY_WORKSPACE_SCHEMA_TYPE\n /**\n * The API expects JSON coming in, but will store a string to save on attribute paths.\n * Consumers must use JSON.parse on the value, put we deploy to the API using ManifestSchemaType[]\n */\n schema: string | Workspace['schema']\n /* api-like version string: date at which the format had a meaningful change */\n version: typeof CURRENT_WORKSPACE_SCHEMA_VERSION | undefined\n workspace: {\n name: string\n title?: string\n }\n\n tag?: string\n}\n\nexport const extractManifestWorkerData = z.object({configPath: z.string(), workDir: z.string()})\n\nexport type ExtractManifestWorkerData = z.infer<typeof extractManifestWorkerData>\n"],"names":["z","SANITY_WORKSPACE_SCHEMA_ID_PREFIX","SANITY_WORKSPACE_SCHEMA_TYPE","CURRENT_WORKSPACE_SCHEMA_VERSION","extractManifestWorkerData","object","configPath","string","workDir"],"mappings":"AAEA,SAAQA,CAAC,QAAO,MAAK;AAErB,OAAO,MAAMC,oCAAoC,YAAW;AAC5D,OAAO,MAAMC,+BAA+B,gBAAe;AAC3D,OAAO,MAAMC,mCAAmC,aAAY;AA2I5D,OAAO,MAAMC,4BAA4BJ,EAAEK,MAAM,CAAC;IAACC,YAAYN,EAAEO,MAAM;IAAIC,SAASR,EAAEO,MAAM;AAAE,GAAE"}
1
+ {"version":3,"sources":["../../../src/actions/manifest/types.ts"],"sourcesContent":["import {type SanityDocumentLike} from '@sanity/types'\nimport {type MediaLibraryConfig} from 'sanity'\nimport {z} from 'zod'\n\nexport const SANITY_WORKSPACE_SCHEMA_ID_PREFIX = '_.schemas'\nexport const SANITY_WORKSPACE_SCHEMA_TYPE = 'system.schema'\nexport const CURRENT_WORKSPACE_SCHEMA_VERSION = '2025-05-01'\n\nexport type ManifestSerializable =\n | boolean\n | ManifestSerializable[]\n | number\n | string\n | {[k: string]: ManifestSerializable}\n\nexport interface CreateManifest {\n createdAt: string\n studioVersion: string | null\n version: number\n workspaces: ManifestWorkspaceFile[]\n}\n\nexport interface AppManifest {\n version: '1'\n\n icon?: string\n title?: string\n}\n\nexport interface ManifestWorkspaceFile extends Omit<CreateWorkspaceManifest, 'schema' | 'tools'> {\n schema: string // filename\n tools: string // filename\n}\n\nexport interface CreateWorkspaceManifest {\n basePath: string\n dataset: string\n /**\n * returns null in the case of the icon not being able to be stringified\n */\n icon: string | null\n name: string\n projectId: string\n schema: ManifestSchemaType[]\n tools: ManifestTool[]\n\n mediaLibrary?: MediaLibraryConfig\n subtitle?: string\n title?: string\n}\n\nexport interface ManifestSchemaType {\n name: string\n type: string\n\n deprecated?: {\n reason: string\n }\n fields?: ManifestField[]\n fieldsets?: ManifestFieldset[]\n hidden?: 'conditional' | boolean\n lists?: ManifestTitledValue[]\n //portable text\n marks?: {\n annotations?: ManifestArrayMember[]\n decorators?: ManifestTitledValue[]\n }\n of?: ManifestArrayMember[]\n options?: Record<string, ManifestSerializable>\n preview?: {\n select: Record<string, string>\n }\n readOnly?: 'conditional' | boolean\n styles?: ManifestTitledValue[]\n title?: string\n to?: ManifestReferenceMember[]\n validation?: ManifestValidationGroup[]\n\n // userland (assignable to ManifestSerializable | undefined)\n // not included to add some typesafty to extractManifest\n // [index: string]: unknown\n}\n\nexport interface ManifestFieldset {\n [index: string]: ManifestSerializable | undefined\n name: string\n\n title?: string\n}\n\nexport interface ManifestTitledValue {\n value: string\n\n title?: string\n}\n\ntype ManifestArrayMember = Omit<ManifestSchemaType, 'name'> & {name?: string}\ntype ManifestReferenceMember = Omit<ManifestSchemaType, 'name'> & {name?: string}\nexport type ManifestField = ManifestSchemaType & {fieldset?: string}\n\nexport interface ManifestValidationGroup {\n rules: ManifestValidationRule[]\n\n level?: 'error' | 'info' | 'warning'\n message?: string\n}\n\nexport type ManifestValidationRule = {\n [index: string]: ManifestSerializable | undefined\n constraint?: ManifestSerializable\n flag: string\n}\n\nexport interface ManifestTool {\n /**\n * returns null in the case of the icon not being able to be stringified\n */\n icon: string | null\n name: string\n title: string\n type: string | null\n}\n\nexport type DefaultWorkspaceSchemaId = `${typeof SANITY_WORKSPACE_SCHEMA_ID_PREFIX}.${string}`\ntype PrefixedWorkspaceSchemaId = `${DefaultWorkspaceSchemaId}.${string}`\nexport type WorkspaceSchemaId = DefaultWorkspaceSchemaId | PrefixedWorkspaceSchemaId\n\nexport interface StoredWorkspaceSchema extends SanityDocumentLike {\n _id: WorkspaceSchemaId\n _type: typeof SANITY_WORKSPACE_SCHEMA_TYPE\n /**\n * The API expects JSON coming in, but will store a string to save on attribute paths.\n * Consumers must use JSON.parse on the value, but we deploy to the API using ManifestSchemaType[]\n */\n schema: ManifestSchemaType[] | string\n /* api-like version string: date at which the format had a meaningful change */\n version: typeof CURRENT_WORKSPACE_SCHEMA_VERSION | undefined\n workspace: {\n name: string\n title?: string\n }\n\n tag?: string\n}\n\nexport const extractManifestWorkerData = z.object({configPath: z.string(), workDir: z.string()})\n\nexport type ExtractManifestWorkerData = z.infer<typeof extractManifestWorkerData>\n"],"names":["z","SANITY_WORKSPACE_SCHEMA_ID_PREFIX","SANITY_WORKSPACE_SCHEMA_TYPE","CURRENT_WORKSPACE_SCHEMA_VERSION","extractManifestWorkerData","object","configPath","string","workDir"],"mappings":"AAEA,SAAQA,CAAC,QAAO,MAAK;AAErB,OAAO,MAAMC,oCAAoC,YAAW;AAC5D,OAAO,MAAMC,+BAA+B,gBAAe;AAC3D,OAAO,MAAMC,mCAAmC,aAAY;AA2I5D,OAAO,MAAMC,4BAA4BJ,EAAEK,MAAM,CAAC;IAACC,YAAYN,EAAEO,MAAM;IAAIC,SAASR,EAAEO,MAAM;AAAE,GAAE"}
@@ -14,7 +14,13 @@ export async function deploySchemas(options) {
14
14
  if (result.type === 'error') {
15
15
  throw new SchemaExtractionError(result.error, result.validation);
16
16
  }
17
- const workspaces = result.workspaces.filter((workspace)=>!workspaceName || workspace.name === workspaceName);
17
+ const workspaces = result.workspaces.filter((workspace)=>!workspaceName || workspace.name === workspaceName).map((workspace)=>({
18
+ dataset: workspace.dataset,
19
+ manifestSchema: workspace.manifestSchema,
20
+ name: workspace.name,
21
+ projectId: workspace.projectId,
22
+ title: workspace.title
23
+ }));
18
24
  if (workspaces.length === 0) {
19
25
  const error = workspaceName ? new Error(`Found no workspaces named "${workspaceName}"`) : new Error('No workspaces found');
20
26
  throw error;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/schema/deploySchemas.ts"],"sourcesContent":["import {studioWorkerTask} from '@sanity/cli-core'\nimport {type SchemaValidationProblemGroup} from '@sanity/types'\nimport {type Workspace} from 'sanity'\n\nimport {type ExtractWorkspaceWorkerData} from './types.js'\nimport {updateWorkspacesSchemas} from './updateWorkspaceSchema.js'\nimport {SchemaExtractionError} from './utils/SchemaExtractionError.js'\n\ninterface DeploySchemasOptions {\n verbose: boolean\n workDir: string\n\n tag?: string\n workspaceName?: string\n}\n\ntype ExtractWorkspaceWorkerMessage =\n | {\n error: string\n type: 'error'\n validation?: SchemaValidationProblemGroup[]\n }\n | {\n type: 'success'\n workspaces: Workspace[]\n }\n\nexport async function deploySchemas(options: DeploySchemasOptions): Promise<void> {\n const {tag, verbose, workDir, workspaceName} = options\n\n const result = await studioWorkerTask<ExtractWorkspaceWorkerMessage>(\n new URL('extractSanityWorkspace.worker.js', import.meta.url),\n {\n name: 'extractSanityWorkspace',\n studioRootPath: workDir,\n workerData: {\n configPath: workDir,\n workDir,\n } satisfies ExtractWorkspaceWorkerData,\n },\n )\n\n if (result.type === 'error') {\n throw new SchemaExtractionError(result.error, result.validation)\n }\n\n const workspaces = result.workspaces.filter(\n (workspace) => !workspaceName || workspace.name === workspaceName,\n )\n if (workspaces.length === 0) {\n const error = workspaceName\n ? new Error(`Found no workspaces named \"${workspaceName}\"`)\n : new Error('No workspaces found')\n throw error\n }\n\n await updateWorkspacesSchemas({\n tag,\n verbose,\n workspaces,\n })\n}\n"],"names":["studioWorkerTask","updateWorkspacesSchemas","SchemaExtractionError","deploySchemas","options","tag","verbose","workDir","workspaceName","result","URL","url","name","studioRootPath","workerData","configPath","type","error","validation","workspaces","filter","workspace","length","Error"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,mBAAkB;AAKjD,SAAQC,uBAAuB,QAAO,6BAA4B;AAClE,SAAQC,qBAAqB,QAAO,mCAAkC;AAqBtE,OAAO,eAAeC,cAAcC,OAA6B;IAC/D,MAAM,EAACC,GAAG,EAAEC,OAAO,EAAEC,OAAO,EAAEC,aAAa,EAAC,GAAGJ;IAE/C,MAAMK,SAAS,MAAMT,iBACnB,IAAIU,IAAI,oCAAoC,YAAYC,GAAG,GAC3D;QACEC,MAAM;QACNC,gBAAgBN;QAChBO,YAAY;YACVC,YAAYR;YACZA;QACF;IACF;IAGF,IAAIE,OAAOO,IAAI,KAAK,SAAS;QAC3B,MAAM,IAAId,sBAAsBO,OAAOQ,KAAK,EAAER,OAAOS,UAAU;IACjE;IAEA,MAAMC,aAAaV,OAAOU,UAAU,CAACC,MAAM,CACzC,CAACC,YAAc,CAACb,iBAAiBa,UAAUT,IAAI,KAAKJ;IAEtD,IAAIW,WAAWG,MAAM,KAAK,GAAG;QAC3B,MAAML,QAAQT,gBACV,IAAIe,MAAM,CAAC,2BAA2B,EAAEf,cAAc,CAAC,CAAC,IACxD,IAAIe,MAAM;QACd,MAAMN;IACR;IAEA,MAAMhB,wBAAwB;QAC5BI;QACAC;QACAa;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/schema/deploySchemas.ts"],"sourcesContent":["import {studioWorkerTask} from '@sanity/cli-core'\nimport {type SchemaValidationProblemGroup} from '@sanity/types'\nimport {type Workspace} from 'sanity'\n\nimport {type ManifestSchemaType} from '../manifest/types.js'\nimport {type ExtractWorkspaceWorkerData} from './types.js'\nimport {updateWorkspacesSchemas, type WorkspaceSchemaInput} from './updateWorkspaceSchema.js'\nimport {SchemaExtractionError} from './utils/SchemaExtractionError.js'\n\ninterface DeploySchemasOptions {\n verbose: boolean\n workDir: string\n\n tag?: string\n workspaceName?: string\n}\n\ntype WorkspaceWithManifest = Workspace & {manifestSchema: ManifestSchemaType[]}\n\ntype ExtractWorkspaceWorkerMessage =\n | {\n error: string\n type: 'error'\n validation?: SchemaValidationProblemGroup[]\n }\n | {\n type: 'success'\n workspaces: WorkspaceWithManifest[]\n }\n\nexport async function deploySchemas(options: DeploySchemasOptions): Promise<void> {\n const {tag, verbose, workDir, workspaceName} = options\n\n const result = await studioWorkerTask<ExtractWorkspaceWorkerMessage>(\n new URL('extractSanityWorkspace.worker.js', import.meta.url),\n {\n name: 'extractSanityWorkspace',\n studioRootPath: workDir,\n workerData: {\n configPath: workDir,\n workDir,\n } satisfies ExtractWorkspaceWorkerData,\n },\n )\n\n if (result.type === 'error') {\n throw new SchemaExtractionError(result.error, result.validation)\n }\n\n const workspaces: WorkspaceSchemaInput[] = result.workspaces\n .filter((workspace) => !workspaceName || workspace.name === workspaceName)\n .map((workspace) => ({\n dataset: workspace.dataset,\n manifestSchema: workspace.manifestSchema,\n name: workspace.name,\n projectId: workspace.projectId,\n title: workspace.title,\n }))\n\n if (workspaces.length === 0) {\n const error = workspaceName\n ? new Error(`Found no workspaces named \"${workspaceName}\"`)\n : new Error('No workspaces found')\n throw error\n }\n\n await updateWorkspacesSchemas({\n tag,\n verbose,\n workspaces,\n })\n}\n"],"names":["studioWorkerTask","updateWorkspacesSchemas","SchemaExtractionError","deploySchemas","options","tag","verbose","workDir","workspaceName","result","URL","url","name","studioRootPath","workerData","configPath","type","error","validation","workspaces","filter","workspace","map","dataset","manifestSchema","projectId","title","length","Error"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,mBAAkB;AAMjD,SAAQC,uBAAuB,QAAkC,6BAA4B;AAC7F,SAAQC,qBAAqB,QAAO,mCAAkC;AAuBtE,OAAO,eAAeC,cAAcC,OAA6B;IAC/D,MAAM,EAACC,GAAG,EAAEC,OAAO,EAAEC,OAAO,EAAEC,aAAa,EAAC,GAAGJ;IAE/C,MAAMK,SAAS,MAAMT,iBACnB,IAAIU,IAAI,oCAAoC,YAAYC,GAAG,GAC3D;QACEC,MAAM;QACNC,gBAAgBN;QAChBO,YAAY;YACVC,YAAYR;YACZA;QACF;IACF;IAGF,IAAIE,OAAOO,IAAI,KAAK,SAAS;QAC3B,MAAM,IAAId,sBAAsBO,OAAOQ,KAAK,EAAER,OAAOS,UAAU;IACjE;IAEA,MAAMC,aAAqCV,OAAOU,UAAU,CACzDC,MAAM,CAAC,CAACC,YAAc,CAACb,iBAAiBa,UAAUT,IAAI,KAAKJ,eAC3Dc,GAAG,CAAC,CAACD,YAAe,CAAA;YACnBE,SAASF,UAAUE,OAAO;YAC1BC,gBAAgBH,UAAUG,cAAc;YACxCZ,MAAMS,UAAUT,IAAI;YACpBa,WAAWJ,UAAUI,SAAS;YAC9BC,OAAOL,UAAUK,KAAK;QACxB,CAAA;IAEF,IAAIP,WAAWQ,MAAM,KAAK,GAAG;QAC3B,MAAMV,QAAQT,gBACV,IAAIoB,MAAM,CAAC,2BAA2B,EAAEpB,cAAc,CAAC,CAAC,IACxD,IAAIoB,MAAM;QACd,MAAMX;IACR;IAEA,MAAMhB,wBAAwB;QAC5BI;QACAC;QACAa;IACF;AACF"}
@@ -1,5 +1,6 @@
1
1
  import { isMainThread, parentPort, workerData } from 'node:worker_threads';
2
2
  import { getStudioWorkspaces, safeStructuredClone } from '@sanity/cli-core';
3
+ import { extractManifestSchemaTypes } from '../manifest/extractWorkspaceManifest.js';
3
4
  import { extractWorkspaceWorkerData } from './types.js';
4
5
  import { extractValidationFromSchemaError } from './utils/extractValidationFromSchemaError.js';
5
6
  if (isMainThread || !parentPort) {
@@ -8,9 +9,16 @@ if (isMainThread || !parentPort) {
8
9
  const { configPath, workDir } = extractWorkspaceWorkerData.parse(workerData);
9
10
  try {
10
11
  const workspaces = await getStudioWorkspaces(configPath);
12
+ // Extract manifest schemas while Schema objects are still live (before structured clone
13
+ // strips class methods like getTypeNames/get). The API expects ManifestSchemaType[], not
14
+ // the runtime Schema class instance.
15
+ const workspacesWithManifest = await Promise.all(workspaces.map(async (workspace)=>({
16
+ ...safeStructuredClone(workspace),
17
+ manifestSchema: await extractManifestSchemaTypes(workspace.schema, workDir)
18
+ })));
11
19
  parentPort.postMessage({
12
20
  type: 'success',
13
- workspaces: safeStructuredClone(workspaces)
21
+ workspaces: workspacesWithManifest
14
22
  });
15
23
  } catch (error) {
16
24
  const validation = await extractValidationFromSchemaError(error, workDir);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/schema/extractSanityWorkspace.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {getStudioWorkspaces, safeStructuredClone} from '@sanity/cli-core'\n\nimport {extractWorkspaceWorkerData} from './types.js'\nimport {extractValidationFromSchemaError} from './utils/extractValidationFromSchemaError.js'\n\nif (isMainThread || !parentPort) {\n throw new Error('Should only be run in a worker!')\n}\n\nconst {configPath, workDir} = extractWorkspaceWorkerData.parse(workerData)\n\ntry {\n const workspaces = await getStudioWorkspaces(configPath)\n\n parentPort.postMessage({\n type: 'success',\n workspaces: safeStructuredClone(workspaces),\n })\n} catch (error) {\n const validation = await extractValidationFromSchemaError(error, workDir)\n parentPort.postMessage({\n error: error instanceof Error ? error.message : String(error),\n type: 'error',\n validation,\n })\n}\n"],"names":["isMainThread","parentPort","workerData","getStudioWorkspaces","safeStructuredClone","extractWorkspaceWorkerData","extractValidationFromSchemaError","Error","configPath","workDir","parse","workspaces","postMessage","type","error","validation","message","String"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,mBAAmB,EAAEC,mBAAmB,QAAO,mBAAkB;AAEzE,SAAQC,0BAA0B,QAAO,aAAY;AACrD,SAAQC,gCAAgC,QAAO,8CAA6C;AAE5F,IAAIN,gBAAgB,CAACC,YAAY;IAC/B,MAAM,IAAIM,MAAM;AAClB;AAEA,MAAM,EAACC,UAAU,EAAEC,OAAO,EAAC,GAAGJ,2BAA2BK,KAAK,CAACR;AAE/D,IAAI;IACF,MAAMS,aAAa,MAAMR,oBAAoBK;IAE7CP,WAAWW,WAAW,CAAC;QACrBC,MAAM;QACNF,YAAYP,oBAAoBO;IAClC;AACF,EAAE,OAAOG,OAAO;IACd,MAAMC,aAAa,MAAMT,iCAAiCQ,OAAOL;IACjER,WAAWW,WAAW,CAAC;QACrBE,OAAOA,iBAAiBP,QAAQO,MAAME,OAAO,GAAGC,OAAOH;QACvDD,MAAM;QACNE;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/schema/extractSanityWorkspace.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {getStudioWorkspaces, safeStructuredClone} from '@sanity/cli-core'\nimport {type Schema} from '@sanity/types'\n\nimport {extractManifestSchemaTypes} from '../manifest/extractWorkspaceManifest.js'\nimport {extractWorkspaceWorkerData} from './types.js'\nimport {extractValidationFromSchemaError} from './utils/extractValidationFromSchemaError.js'\n\nif (isMainThread || !parentPort) {\n throw new Error('Should only be run in a worker!')\n}\n\nconst {configPath, workDir} = extractWorkspaceWorkerData.parse(workerData)\n\ntry {\n const workspaces = await getStudioWorkspaces(configPath)\n\n // Extract manifest schemas while Schema objects are still live (before structured clone\n // strips class methods like getTypeNames/get). The API expects ManifestSchemaType[], not\n // the runtime Schema class instance.\n const workspacesWithManifest = await Promise.all(\n workspaces.map(async (workspace) => ({\n ...safeStructuredClone(workspace),\n manifestSchema: await extractManifestSchemaTypes(workspace.schema as Schema, workDir),\n })),\n )\n\n parentPort.postMessage({\n type: 'success',\n workspaces: workspacesWithManifest,\n })\n} catch (error) {\n const validation = await extractValidationFromSchemaError(error, workDir)\n parentPort.postMessage({\n error: error instanceof Error ? error.message : String(error),\n type: 'error',\n validation,\n })\n}\n"],"names":["isMainThread","parentPort","workerData","getStudioWorkspaces","safeStructuredClone","extractManifestSchemaTypes","extractWorkspaceWorkerData","extractValidationFromSchemaError","Error","configPath","workDir","parse","workspaces","workspacesWithManifest","Promise","all","map","workspace","manifestSchema","schema","postMessage","type","error","validation","message","String"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,mBAAmB,EAAEC,mBAAmB,QAAO,mBAAkB;AAGzE,SAAQC,0BAA0B,QAAO,0CAAyC;AAClF,SAAQC,0BAA0B,QAAO,aAAY;AACrD,SAAQC,gCAAgC,QAAO,8CAA6C;AAE5F,IAAIP,gBAAgB,CAACC,YAAY;IAC/B,MAAM,IAAIO,MAAM;AAClB;AAEA,MAAM,EAACC,UAAU,EAAEC,OAAO,EAAC,GAAGJ,2BAA2BK,KAAK,CAACT;AAE/D,IAAI;IACF,MAAMU,aAAa,MAAMT,oBAAoBM;IAE7C,wFAAwF;IACxF,yFAAyF;IACzF,qCAAqC;IACrC,MAAMI,yBAAyB,MAAMC,QAAQC,GAAG,CAC9CH,WAAWI,GAAG,CAAC,OAAOC,YAAe,CAAA;YACnC,GAAGb,oBAAoBa,UAAU;YACjCC,gBAAgB,MAAMb,2BAA2BY,UAAUE,MAAM,EAAYT;QAC/E,CAAA;IAGFT,WAAWmB,WAAW,CAAC;QACrBC,MAAM;QACNT,YAAYC;IACd;AACF,EAAE,OAAOS,OAAO;IACd,MAAMC,aAAa,MAAMhB,iCAAiCe,OAAOZ;IACjET,WAAWmB,WAAW,CAAC;QACrBE,OAAOA,iBAAiBd,QAAQc,MAAME,OAAO,GAAGC,OAAOH;QACvDD,MAAM;QACNE;IACF;AACF"}
@@ -27,7 +27,7 @@ import { getWorkspaceSchemaId } from './utils/workspaceSchemaId.js';
27
27
  * Updates a workspace schema in the dataset.
28
28
  */ async function updateWorkspaceSchema(args) {
29
29
  const { tag, verbose, workspace } = args;
30
- const { dataset, projectId } = workspace;
30
+ const { dataset, manifestSchema, projectId } = workspace;
31
31
  const { idWarning, safeBaseId: id } = getWorkspaceSchemaId({
32
32
  tag,
33
33
  workspaceName: workspace.name
@@ -37,7 +37,7 @@ import { getWorkspaceSchemaId } from './utils/workspaceSchemaId.js';
37
37
  await updateSchemas(dataset, projectId, [
38
38
  {
39
39
  // the API will stringify the schema – we send as JSON
40
- schema: workspace.schema,
40
+ schema: manifestSchema,
41
41
  tag,
42
42
  version: CURRENT_WORKSPACE_SCHEMA_VERSION,
43
43
  workspace: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/schema/updateWorkspaceSchema.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {ux} from '@oclif/core/ux'\nimport {spinner} from '@sanity/cli-core/ux'\nimport partition from 'lodash-es/partition.js'\nimport {type Workspace} from 'sanity'\n\nimport {updateSchemas} from '../../services/schemas.js'\nimport {CURRENT_WORKSPACE_SCHEMA_VERSION, type StoredWorkspaceSchema} from '../manifest/types.js'\nimport {SCHEMA_PERMISSION_HELP_TEXT} from './utils/schemaStoreValidation.js'\nimport {getWorkspaceSchemaId} from './utils/workspaceSchemaId.js'\n\n/**\n * Updates the schemas for a list of workspaces.\n */\nexport async function updateWorkspacesSchemas(args: {\n tag?: string\n verbose: boolean\n workspaces: Workspace[]\n}) {\n const {tag, verbose, workspaces} = args\n\n /* Known caveat: we _don't_ rollback failed operations or partial success */\n const results = await Promise.allSettled(\n workspaces.map(async (workspace): Promise<void> => {\n await updateWorkspaceSchema({\n tag,\n verbose,\n workspace,\n })\n }),\n )\n\n const [fulfilledUpdates, rejectedUpdates] = partition(\n results,\n (result) => result.status === 'fulfilled',\n )\n\n if (rejectedUpdates.length > 0) {\n throw new Error(\n `Failed to deploy ${rejectedUpdates.length}/${workspaces.length} schemas. Successfully deployed ${fulfilledUpdates.length}/${workspaces.length} schemas.`,\n )\n }\n\n spinner(`Deployed ${fulfilledUpdates.length}/${workspaces.length} schemas`).succeed()\n}\n\n/**\n * Updates a workspace schema in the dataset.\n */\nasync function updateWorkspaceSchema(args: {tag?: string; verbose: boolean; workspace: Workspace}) {\n const {tag, verbose, workspace} = args\n\n const {dataset, projectId} = workspace\n\n const {idWarning, safeBaseId: id} = getWorkspaceSchemaId({\n tag,\n workspaceName: workspace.name,\n })\n\n if (idWarning) ux.warn(idWarning)\n\n try {\n await updateSchemas<Omit<StoredWorkspaceSchema, '_id' | '_type'>[]>(dataset, projectId, [\n {\n // the API will stringify the schema – we send as JSON\n schema: workspace.schema,\n tag,\n version: CURRENT_WORKSPACE_SCHEMA_VERSION,\n workspace: {\n name: workspace.name,\n title: workspace.title,\n },\n },\n ])\n\n if (verbose) {\n ux.stdout(\n styleText('gray', `↳ schemaId: ${id}, projectId: ${projectId}, dataset: ${dataset}`),\n )\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n if (\n err instanceof Error &&\n 'statusCode' in err &&\n (err as {statusCode: unknown}).statusCode === 401\n ) {\n ux.warn(\n `↳ No permissions to write schema for workspace \"${workspace.name}\" in dataset \"${workspace.dataset}\". ${\n SCHEMA_PERMISSION_HELP_TEXT\n }:\\n ${styleText('red', message)}`,\n )\n } else {\n ux.stdout(\n styleText(\n 'red',\n `↳ Error deploying schema for workspace \"${workspace.name}\":\\n ${styleText('red', message)}`,\n ),\n )\n }\n\n throw err\n }\n}\n"],"names":["styleText","ux","spinner","partition","updateSchemas","CURRENT_WORKSPACE_SCHEMA_VERSION","SCHEMA_PERMISSION_HELP_TEXT","getWorkspaceSchemaId","updateWorkspacesSchemas","args","tag","verbose","workspaces","results","Promise","allSettled","map","workspace","updateWorkspaceSchema","fulfilledUpdates","rejectedUpdates","result","status","length","Error","succeed","dataset","projectId","idWarning","safeBaseId","id","workspaceName","name","warn","schema","version","title","stdout","err","message","String","statusCode"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,EAAE,QAAO,iBAAgB;AACjC,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,OAAOC,eAAe,yBAAwB;AAG9C,SAAQC,aAAa,QAAO,4BAA2B;AACvD,SAAQC,gCAAgC,QAAmC,uBAAsB;AACjG,SAAQC,2BAA2B,QAAO,mCAAkC;AAC5E,SAAQC,oBAAoB,QAAO,+BAA8B;AAEjE;;CAEC,GACD,OAAO,eAAeC,wBAAwBC,IAI7C;IACC,MAAM,EAACC,GAAG,EAAEC,OAAO,EAAEC,UAAU,EAAC,GAAGH;IAEnC,0EAA0E,GAC1E,MAAMI,UAAU,MAAMC,QAAQC,UAAU,CACtCH,WAAWI,GAAG,CAAC,OAAOC;QACpB,MAAMC,sB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D,IACEA,eAAed,SACf,gBAAgBc,OAChB,AAACA,IAA8BG,UAAU,KAAK,KAC9C;YACAxC,GAAGgC,IAAI,CACL,CAAC,gDAAgD,EAAEhB,UAAUe,IAAI,CAAC,cAAc,EAAEf,UAAUS,OAAO,CAAC,GAAG,EACrGpB,4BACD,KAAK,EAAEN,UAAU,OAAOuC,UAAU;QAEvC,OAAO;YACLtC,GAAGoC,MAAM,CACPrC,UACE,OACA,CAAC,wCAAwC,EAAEiB,UAAUe,IAAI,CAAC,MAAM,EAAEhC,UAAU,OAAOuC,UAAU;QAGnG;QAEA,MAAMD;IACR;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/schema/updateWorkspaceSchema.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {ux} from '@oclif/core/ux'\nimport {spinner} from '@sanity/cli-core/ux'\nimport partition from 'lodash-es/partition.js'\n\nimport {updateSchemas} from '../../services/schemas.js'\nimport {\n CURRENT_WORKSPACE_SCHEMA_VERSION,\n type ManifestSchemaType,\n type StoredWorkspaceSchema,\n} from '../manifest/types.js'\nimport {SCHEMA_PERMISSION_HELP_TEXT} from './utils/schemaStoreValidation.js'\nimport {getWorkspaceSchemaId} from './utils/workspaceSchemaId.js'\n\n/**\n * Workspace metadata + pre-extracted manifest schema for deployment.\n * The schema must already be in ManifestSchemaType[] format (extracted from\n * the live Schema object before any structured clone boundary).\n */\nexport interface WorkspaceSchemaInput {\n dataset: string\n manifestSchema: ManifestSchemaType[]\n name: string\n projectId: string\n\n title?: string\n}\n\n/**\n * Updates the schemas for a list of workspaces.\n */\nexport async function updateWorkspacesSchemas(args: {\n tag?: string\n verbose: boolean\n workspaces: WorkspaceSchemaInput[]\n}) {\n const {tag, verbose, workspaces} = args\n\n /* Known caveat: we _don't_ rollback failed operations or partial success */\n const results = await Promise.allSettled(\n workspaces.map(async (workspace): Promise<void> => {\n await updateWorkspaceSchema({\n tag,\n verbose,\n workspace,\n })\n }),\n )\n\n const [fulfilledUpdates, rejectedUpdates] = partition(\n results,\n (result) => result.status === 'fulfilled',\n )\n\n if (rejectedUpdates.length > 0) {\n throw new Error(\n `Failed to deploy ${rejectedUpdates.length}/${workspaces.length} schemas. Successfully deployed ${fulfilledUpdates.length}/${workspaces.length} schemas.`,\n )\n }\n\n spinner(`Deployed ${fulfilledUpdates.length}/${workspaces.length} schemas`).succeed()\n}\n\n/**\n * Updates a workspace schema in the dataset.\n */\nasync function updateWorkspaceSchema(args: {\n tag?: string\n verbose: boolean\n workspace: WorkspaceSchemaInput\n}) {\n const {tag, verbose, workspace} = args\n\n const {dataset, manifestSchema, projectId} = workspace\n\n const {idWarning, safeBaseId: id} = getWorkspaceSchemaId({\n tag,\n workspaceName: workspace.name,\n })\n\n if (idWarning) ux.warn(idWarning)\n\n try {\n await updateSchemas<Omit<StoredWorkspaceSchema, '_id' | '_type'>[]>(dataset, projectId, [\n {\n // the API will stringify the schema – we send as JSON\n schema: manifestSchema,\n tag,\n version: CURRENT_WORKSPACE_SCHEMA_VERSION,\n workspace: {\n name: workspace.name,\n title: workspace.title,\n },\n },\n ])\n\n if (verbose) {\n ux.stdout(\n styleText('gray', `↳ schemaId: ${id}, projectId: ${projectId}, dataset: ${dataset}`),\n )\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n if (\n err instanceof Error &&\n 'statusCode' in err &&\n (err as {statusCode: unknown}).statusCode === 401\n ) {\n ux.warn(\n `↳ No permissions to write schema for workspace \"${workspace.name}\" in dataset \"${workspace.dataset}\". ${\n SCHEMA_PERMISSION_HELP_TEXT\n }:\\n ${styleText('red', message)}`,\n )\n } else {\n ux.stdout(\n styleText(\n 'red',\n `↳ Error deploying schema for workspace \"${workspace.name}\":\\n ${styleText('red', message)}`,\n ),\n )\n }\n\n throw err\n }\n}\n"],"names":["styleText","ux","spinner","partition","updateSchemas","CURRENT_WORKSPACE_SCHEMA_VERSION","SCHEMA_PERMISSION_HELP_TEXT","getWorkspaceSchemaId","updateWorkspacesSchemas","args","tag","verbose","workspaces","results","Promise","allSettled","map","workspace","updateWorkspaceSchema","fulfilledUpdates","rejectedUpdates","result","status","length","Error","succeed","dataset","manifestSchema","projectId","idWarning","safeBaseId","id","workspaceName","name","warn","schema","version","title","stdout","err","message","String","statusCode"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,EAAE,QAAO,iBAAgB;AACjC,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,OAAOC,eAAe,yBAAwB;AAE9C,SAAQC,aAAa,QAAO,4BAA2B;AACvD,SACEC,gCAAgC,QAG3B,uBAAsB;AAC7B,SAAQC,2BAA2B,QAAO,mCAAkC;AAC5E,SAAQC,oBAAoB,QAAO,+BAA8B;AAgBjE;;CAEC,GACD,OAAO,eAAeC,wBAAwBC,IAI7C;IACC,MAAM,EAACC,GAAG,EAAEC,OAAO,EAAEC,UAAU,EAAC,GAAGH;IAEnC,0EAA0E,GAC1E,MAAMI,UAAU,MAAMC,QAAQC,UAAU,CACtCH,WAAWI,GAAG,CAAC,OAAOC;QACpB,MAAMC,sBAAsB;YAC1BR;YACAC;YACAM;QACF;IACF;IAGF,MAAM,CAACE,kBAAkBC,gBAAgB,GAAGjB,UAC1CU,SACA,CAACQ,SAAWA,OAAOC,MAAM,KAAK;IAGhC,IAAIF,gBAAgBG,MAAM,GAAG,GAAG;QAC9B,MAAM,IAAIC,MACR,CAAC,iBAAiB,EAAEJ,gBAAgBG,MAAM,CAAC,CAAC,EAAEX,WAAWW,MAAM,CAAC,gCAAgC,EAAEJ,iBAAiBI,MAAM,CAAC,CAAC,EAAEX,WAAWW,MAAM,CAAC,SAAS,CAAC;IAE7J;IAEArB,QAAQ,CAAC,SAAS,EAAEiB,iBAAiBI,MAAM,CAAC,CAAC,EAAEX,WAAWW,MAAM,CAAC,QAAQ,CAAC,EAAEE,OAAO;AACrF;AAEA;;CAEC,GACD,eAAeP,sBAAsBT,IAIpC;IACC,MAAM,EAACC,GAAG,EAAEC,OAAO,EAAEM,SAAS,EAAC,GAAGR;IAElC,MAAM,EAACiB,OAAO,EAAEC,cAAc,EAAEC,SAAS,EAAC,GAAGX;IAE7C,MAAM,EAACY,SAAS,EAAEC,YAAYC,EAAE,EAAC,GAAGxB,qBAAqB;QACvDG;QACAsB,eAAef,UAAUgB,IAAI;IAC/B;IAEA,IAAIJ,WAAW5B,GAAGiC,IAAI,CAACL;IAEvB,IAAI;QACF,MAAMzB,cAA8DsB,SAASE,WAAW;YACtF;gBACE,sDAAsD;gBACtDO,QAAQR;gBACRjB;gBACA0B,SAAS/B;gBACTY,WAAW;oBACTgB,MAAMhB,UAAUgB,IAAI;oBACpBI,OAAOpB,UAAUoB,KAAK;gBACxB;YACF;SACD;QAED,IAAI1B,SAAS;YACXV,GAAGqC,MAAM,CACPtC,UAAU,QAAQ,CAAC,YAAY,EAAE+B,GAAG,aAAa,EAAEH,UAAU,WAAW,EAAEF,SAAS;QAEvF;IACF,EAAE,OAAOa,KAAK;QACZ,MAAMC,UAAUD,eAAef,QAAQe,IAAIC,OAAO,GAAGC,OAAOF;QAC5D,IACEA,eAAef,SACf,gBAAgBe,OAChB,AAACA,IAA8BG,UAAU,KAAK,KAC9C;YACAzC,GAAGiC,IAAI,CACL,CAAC,gDAAgD,EAAEjB,UAAUgB,IAAI,CAAC,cAAc,EAAEhB,UAAUS,OAAO,CAAC,GAAG,EACrGpB,4BACD,KAAK,EAAEN,UAAU,OAAOwC,UAAU;QAEvC,OAAO;YACLvC,GAAGqC,MAAM,CACPtC,UACE,OACA,CAAC,wCAAwC,EAAEiB,UAAUgB,IAAI,CAAC,MAAM,EAAEjC,UAAU,OAAOwC,UAAU;QAGnG;QAEA,MAAMD;IACR;AACF"}
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import { styleText } from 'node:util';
3
3
  import { Flags } from '@oclif/core';
4
- import { SanityCommand } from '@sanity/cli-core';
4
+ import { ProjectRootNotFoundError, SanityCommand } from '@sanity/cli-core';
5
5
  import omit from 'lodash-es/omit.js';
6
6
  import padStart from 'lodash-es/padStart.js';
7
7
  import { formatObject, printKeyValue } from '../actions/debug/formatters.js';
@@ -23,8 +23,13 @@ export class Debug extends SanityCommand {
23
23
  async run() {
24
24
  const { flags } = this;
25
25
  try {
26
- const projectRoot = await this.getProjectRoot();
27
- const cliConfig = await this.getCliConfig();
26
+ let projectRoot;
27
+ try {
28
+ projectRoot = await this.getProjectRoot();
29
+ } catch (err) {
30
+ if (!(err instanceof ProjectRootNotFoundError)) throw err;
31
+ }
32
+ const cliConfig = projectRoot ? await this.getCliConfig() : undefined;
28
33
  const { auth, globalConfig, project, projectConfig, user, versions } = await gatherDebugInfo({
29
34
  cliConfig,
30
35
  includeSecrets: flags.secrets,
@@ -69,11 +74,17 @@ export class Debug extends SanityCommand {
69
74
  'authToken'
70
75
  ]);
71
76
  this.log(` ${formatObject(globalCfg).replaceAll('\n', '\n ')}\n`);
72
- // Project configuration (projectDir/sanity.json)
73
- if (projectConfig) {
74
- const configLocation = projectConfig ? ` (${styleText('yellow', path.relative(process.cwd(), projectRoot.path))})` : '';
77
+ // Project configuration (projectDir/sanity.cli.ts)
78
+ if (!projectRoot) {
79
+ this.log('No project found\n');
80
+ } else if (projectConfig instanceof Error) {
81
+ this.log(`CLI configuration error: ${styleText('red', projectConfig.message)}\n`);
82
+ } else if (projectConfig) {
83
+ const configLocation = ` (${styleText('yellow', path.relative(process.cwd(), projectRoot.path))})`;
75
84
  this.log(`Project config${configLocation}:`);
76
85
  this.log(` ${formatObject(projectConfig).replaceAll('\n', '\n ')}`);
86
+ } else {
87
+ this.log('No CLI configuration file found\n');
77
88
  }
78
89
  // Print installed package versions
79
90
  if (versions) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/debug.ts"],"sourcesContent":["import path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {Flags} from '@oclif/core'\nimport {SanityCommand} from '@sanity/cli-core'\nimport omit from 'lodash-es/omit.js'\nimport padStart from 'lodash-es/padStart.js'\n\nimport {formatObject, printKeyValue} from '../actions/debug/formatters.js'\nimport {gatherDebugInfo} from '../actions/debug/gatherDebugInfo.js'\nimport {getGlobalConfigLocation} from '../actions/debug/getGlobalConfigLocation.js'\nimport {getDisplayName, getFormatters} from '../actions/versions/getFormatters.js'\n\nexport class Debug extends SanityCommand<typeof Debug> {\n static override description = 'Provides diagnostic info for Sanity Studio troubleshooting'\n\n static override examples = [\n '<%= config.bin %> <%= command.id %>',\n '<%= config.bin %> <%= command.id %> --secrets',\n ]\n\n static override flags = {\n secrets: Flags.boolean({\n default: false,\n description: 'Include API keys in output',\n }),\n }\n\n public async run(): Promise<void> {\n const {flags} = this\n\n try {\n const projectRoot = await this.getProjectRoot()\n const cliConfig = await this.getCliConfig()\n\n const {auth, globalConfig, project, projectConfig, user, versions} = await gatherDebugInfo({\n cliConfig,\n includeSecrets: flags.secrets,\n projectRoot,\n })\n\n this.output.log('\\nUser:')\n if (user instanceof Error) {\n this.log(` ${styleText('red', user.message)}\\n`)\n } else if (user) {\n printKeyValue({\n ID: user.id,\n Name: user.name,\n // eslint-disable-next-line perfectionist/sort-objects\n Email: user.email,\n Roles: project && 'userRoles' in project ? project.userRoles : undefined,\n })\n }\n\n // Project info (API-based)\n if (project && 'id' in project) {\n this.log('Project:')\n printKeyValue({\n ID: project.id,\n // eslint-disable-next-line perfectionist/sort-objects\n 'Display name': project.displayName,\n })\n }\n\n // Auth info\n if (auth.hasToken) {\n this.log('Authentication:')\n printKeyValue({\n 'Auth token': flags.secrets ? auth.authToken : `<redacted>`,\n 'User type': globalConfig.authType || 'normal',\n })\n\n if (!flags.secrets) {\n this.log(' (run with --secrets to reveal token)\\n')\n }\n }\n\n // Global configuration (user home dir config file)\n this.log(`Global config (${styleText('yellow', getGlobalConfigLocation())}):`)\n const globalCfg = omit(globalConfig, ['authType', 'authToken'])\n this.log(` ${formatObject(globalCfg).replaceAll('\\n', '\\n ')}\\n`)\n\n // Project configuration (projectDir/sanity.json)\n if (projectConfig) {\n const configLocation = projectConfig\n ? ` (${styleText('yellow', path.relative(process.cwd(), projectRoot.path))})`\n : ''\n\n this.log(`Project config${configLocation}:`)\n this.log(` ${formatObject(projectConfig).replaceAll('\\n', '\\n ')}`)\n }\n\n // Print installed package versions\n if (versions) {\n this.log('\\nPackage versions:')\n\n const {formatName, versionLength} = getFormatters(versions)\n for (const mod of versions) {\n const version = padStart(mod.installed || '<missing>', versionLength)\n const latest =\n mod.installed === mod.latest\n ? styleText('green', '(up to date)')\n : `(latest: ${styleText('yellow', mod.latest)})`\n\n this.log(`${formatName(getDisplayName(mod))} ${version} ${latest}`)\n }\n\n this.log('')\n }\n } catch (error) {\n this.error(\n `Failed to gather debug information: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n }\n}\n"],"names":["path","styleText","Flags","SanityCommand","omit","padStart","formatObject","printKeyValue","gatherDebugInfo","getGlobalConfigLocation","getDisplayName","getFormatters","Debug","description","examples","flags","secrets","boolean","default","run","projectRoot","getProjectRoot","cliConfig","getCliConfig","auth","globalConfig","project","projectConfig","user","versions","includeSecrets","output","log","Error","message","ID","id","Name","name","Email","email","Roles","userRoles","undefined","displayName","hasToken","authToken","authType","globalCfg","replaceAll","configLocation","relative","process","cwd","formatName","versionLength","mod","version","installed","latest","error"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAQC,KAAK,QAAO,cAAa;AACjC,SAAQC,aAAa,QAAO,mBAAkB;AAC9C,OAAOC,UAAU,oBAAmB;AACpC,OAAOC,cAAc,wBAAuB;AAE5C,SAAQC,YAAY,EAAEC,aAAa,QAAO,iCAAgC;AAC1E,SAAQC,eAAe,QAAO,sCAAqC;AACnE,SAAQC,uBAAuB,QAAO,8CAA6C;AACnF,SAAQC,cAAc,EAAEC,aAAa,QAAO,uCAAsC;AAElF,OAAO,MAAMC,cAAcT;IACzB,OAAgBU,cAAc,6DAA4D;IAE1F,OAAgBC,WAAW;QACzB;QACA;KACD,CAAA;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IAAI,CAACA,KAAK,CACR,CAAC,oCAAoC,EAAEA,iBAAiB3B,QAAQ2B,MAAM1B,OAAO,GAAG,iBAAiB;QAErG;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/commands/debug.ts"],"sourcesContent":["import path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {Flags} from '@oclif/core'\nimport {ProjectRootNotFoundError, SanityCommand} from '@sanity/cli-core'\nimport omit from 'lodash-es/omit.js'\nimport padStart from 'lodash-es/padStart.js'\n\nimport {formatObject, printKeyValue} from '../actions/debug/formatters.js'\nimport {gatherDebugInfo} from '../actions/debug/gatherDebugInfo.js'\nimport {getGlobalConfigLocation} from '../actions/debug/getGlobalConfigLocation.js'\nimport {getDisplayName, getFormatters} from '../actions/versions/getFormatters.js'\n\nexport class Debug extends SanityCommand<typeof Debug> {\n static override description = 'Provides diagnostic info for Sanity Studio troubleshooting'\n\n static override examples = [\n '<%= config.bin %> <%= command.id %>',\n '<%= config.bin %> <%= command.id %> --secrets',\n ]\n\n static override flags = {\n secrets: Flags.boolean({\n default: false,\n description: 'Include API keys in output',\n }),\n }\n\n public async run(): Promise<void> {\n const {flags} = this\n\n try {\n let projectRoot\n try {\n projectRoot = await this.getProjectRoot()\n } catch (err) {\n if (!(err instanceof ProjectRootNotFoundError)) throw err\n }\n\n const cliConfig = projectRoot ? await this.getCliConfig() : undefined\n\n const {auth, globalConfig, project, projectConfig, user, versions} = await gatherDebugInfo({\n cliConfig,\n includeSecrets: flags.secrets,\n projectRoot,\n })\n\n this.output.log('\\nUser:')\n if (user instanceof Error) {\n this.log(` ${styleText('red', user.message)}\\n`)\n } else if (user) {\n printKeyValue({\n ID: user.id,\n Name: user.name,\n // eslint-disable-next-line perfectionist/sort-objects\n Email: user.email,\n Roles: project && 'userRoles' in project ? project.userRoles : undefined,\n })\n }\n\n // Project info (API-based)\n if (project && 'id' in project) {\n this.log('Project:')\n printKeyValue({\n ID: project.id,\n // eslint-disable-next-line perfectionist/sort-objects\n 'Display name': project.displayName,\n })\n }\n\n // Auth info\n if (auth.hasToken) {\n this.log('Authentication:')\n printKeyValue({\n 'Auth token': flags.secrets ? auth.authToken : `<redacted>`,\n 'User type': globalConfig.authType || 'normal',\n })\n\n if (!flags.secrets) {\n this.log(' (run with --secrets to reveal token)\\n')\n }\n }\n\n // Global configuration (user home dir config file)\n this.log(`Global config (${styleText('yellow', getGlobalConfigLocation())}):`)\n const globalCfg = omit(globalConfig, ['authType', 'authToken'])\n this.log(` ${formatObject(globalCfg).replaceAll('\\n', '\\n ')}\\n`)\n\n // Project configuration (projectDir/sanity.cli.ts)\n if (!projectRoot) {\n this.log('No project found\\n')\n } else if (projectConfig instanceof Error) {\n this.log(`CLI configuration error: ${styleText('red', projectConfig.message)}\\n`)\n } else if (projectConfig) {\n const configLocation = ` (${styleText('yellow', path.relative(process.cwd(), projectRoot.path))})`\n\n this.log(`Project config${configLocation}:`)\n this.log(` ${formatObject(projectConfig).replaceAll('\\n', '\\n ')}`)\n } else {\n this.log('No CLI configuration file found\\n')\n }\n\n // Print installed package versions\n if (versions) {\n this.log('\\nPackage versions:')\n\n const {formatName, versionLength} = getFormatters(versions)\n for (const mod of versions) {\n const version = padStart(mod.installed || '<missing>', versionLength)\n const latest =\n mod.installed === mod.latest\n ? styleText('green', '(up to date)')\n : `(latest: ${styleText('yellow', mod.latest)})`\n\n this.log(`${formatName(getDisplayName(mod))} ${version} ${latest}`)\n }\n\n this.log('')\n }\n } catch (error) {\n this.error(\n `Failed to gather debug information: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n }\n}\n"],"names":["path","styleText","Flags","ProjectRootNotFoundError","SanityCommand","omit","padStart","formatObject","printKeyValue","gatherDebugInfo","getGlobalConfigLocation","getDisplayName","getFormatters","Debug","description","examples","flags","secrets","boolean","default","run","projectRoot","getProjectRoot","err","cliConfig","getCliConfig","undefined","auth","globalConfig","project","projectConfig","user","versions","includeSecrets","output","log","Error","message","ID","id","Name","name","Email","email","Roles","userRoles","displayName","hasToken","authToken","authType","globalCfg","replaceAll","configLocation","relative","process","cwd","formatName","versionLength","mod","version","installed","latest","error"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAQC,KAAK,QAAO,cAAa;AACjC,SAAQC,wBAAwB,EAAEC,aAAa,QAAO,mBAAkB;AACxE,OAAOC,UAAU,oBAAmB;AACpC,OAAOC,cAAc,wBAAuB;AAE5C,SAAQC,YAAY,EAAEC,aAAa,QAAO,iCAAgC;AAC1E,SAAQC,eAAe,QAAO,sCAAqC;AACnE,SAAQC,uBAAuB,QAAO,8CAA6C;AACnF,SAAQC,cAAc,EAAEC,aAAa,QAAO,uCAAsC;AAElF,OAAO,MAAMC,cAAcT;IACzB,OAAgBU,cAAc,6DAA4D;IAE1F,OAAgBC,WAAW;QACzB;QACA;KACD,CAAA;IAED,OAAgBC,QAAQ;QACtBC,SAASf,MAAMgB,OAAO,CAAC;YACrBC,SAAS;YACTL,aAAa;QACf;IACF,EAAC;IAED,MAAaM,MAAqB;QAChC,MAAM,EAACJ,KAAK,EAAC,GAAG,IAAI;QAEpB,IAAI;YACF,IAAIK;YACJ,IAAI;gBACFA,cAAc,MAAM,IAAI,CAACC,cAAc;YACzC,EAAE,OAAOC,KAAK;gBACZ,IAAI,CAAEA,CAAAA,eAAepB,wBAAuB,GAAI,MAAMoB;YACxD;YAEA,MAAMC,YAAYH,cAAc,MAAM,IAAI,CAACI,YAAY,KAAKC;YAE5D,MAAM,EAACC,IAAI,EAAEC,YAAY,EAAEC,OAAO,EAAEC,aAAa,EAAEC,IAAI,EAAEC,QAAQ,EAAC,GAAG,MAAMvB,gBAAgB;gBACzFe;gBACAS,gBAAgBjB,MAAMC,OAAO;gBAC7BI;YACF;YAEA,IAAI,CAACa,MAAM,CAACC,GAAG,CAAC;YAChB,IAAIJ,gBAAgBK,OAAO;gBACzB,IAAI,CAACD,GAAG,CAAC,CAAC,EAAE,EAAElC,UAAU,OAAO8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iBAAiB,CAAC,EAAE,EAAEnD,UAAU,UAAUD,KAAKqD,QAAQ,CAACC,QAAQC,GAAG,IAAIlC,YAAYrB,IAAI,GAAG,CAAC,CAAC;gBAElG,IAAI,CAACmC,GAAG,CAAC,CAAC,cAAc,EAAEiB,eAAe,CAAC,CAAC;gBAC3C,IAAI,CAACjB,GAAG,CAAC,CAAC,EAAE,EAAE5B,aAAauB,eAAeqB,UAAU,CAAC,MAAM,SAAS;YACtE,OAAO;gBACL,IAAI,CAAChB,GAAG,CAAC;YACX;YAEA,mCAAmC;YACnC,IAAIH,UAAU;gBACZ,IAAI,CAACG,GAAG,CAAC;gBAET,MAAM,EAACqB,UAAU,EAAEC,aAAa,EAAC,GAAG7C,cAAcoB;gBAClD,KAAK,MAAM0B,OAAO1B,SAAU;oBAC1B,MAAM2B,UAAUrD,SAASoD,IAAIE,SAAS,IAAI,aAAaH;oBACvD,MAAMI,SACJH,IAAIE,SAAS,KAAKF,IAAIG,MAAM,GACxB5D,UAAU,SAAS,kBACnB,CAAC,SAAS,EAAEA,UAAU,UAAUyD,IAAIG,MAAM,EAAE,CAAC,CAAC;oBAEpD,IAAI,CAAC1B,GAAG,CAAC,GAAGqB,WAAW7C,eAAe+C,MAAM,CAAC,EAAEC,QAAQ,CAAC,EAAEE,QAAQ;gBACpE;gBAEA,IAAI,CAAC1B,GAAG,CAAC;YACX;QACF,EAAE,OAAO2B,OAAO;YACd,IAAI,CAACA,KAAK,CACR,CAAC,oCAAoC,EAAEA,iBAAiB1B,QAAQ0B,MAAMzB,OAAO,GAAG,iBAAiB;QAErG;IACF;AACF"}
@@ -4943,5 +4943,5 @@
4943
4943
  ]
4944
4944
  }
4945
4945
  },
4946
- "version": "6.1.4"
4946
+ "version": "6.1.5"
4947
4947
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli",
3
- "version": "6.1.4",
3
+ "version": "6.1.5",
4
4
  "description": "Sanity CLI tool for managing Sanity projects and organizations",
5
5
  "keywords": [
6
6
  "cli",
@@ -151,8 +151,8 @@
151
151
  "vitest": "^4.0.18",
152
152
  "@repo/package.config": "0.0.1",
153
153
  "@repo/tsconfig": "3.70.0",
154
- "@sanity/cli-test": "0.2.4",
155
- "@sanity/eslint-config-cli": "1.0.0"
154
+ "@sanity/eslint-config-cli": "1.0.0",
155
+ "@sanity/cli-test": "0.2.4"
156
156
  },
157
157
  "engines": {
158
158
  "node": ">=20.19.1 <22 || >=22.12"