@sanity/cli 3.75.1 → 3.76.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_chunks-cjs/cli.js +22 -14
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/lib/index.d.mts +1 -0
- package/lib/index.d.ts +1 -0
- package/package.json +8 -8
- package/src/actions/init-project/bootstrapLocalTemplate.ts +4 -1
- package/src/actions/init-project/createCoreAppCliConfig.ts +2 -1
- package/src/actions/init-project/createStudioConfig.ts +1 -0
- package/src/actions/init-project/initProject.ts +21 -12
- package/src/types.ts +1 -0
package/lib/index.d.mts
CHANGED
package/lib/index.d.ts
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sanity/cli",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.76.1",
|
4
4
|
"description": "Sanity CLI tool for managing Sanity installations, managing plugins, schemas and datasets",
|
5
5
|
"keywords": [
|
6
6
|
"sanity",
|
@@ -57,11 +57,11 @@
|
|
57
57
|
},
|
58
58
|
"dependencies": {
|
59
59
|
"@babel/traverse": "^7.23.5",
|
60
|
-
"@sanity/client": "^6.
|
61
|
-
"@sanity/codegen": "3.
|
60
|
+
"@sanity/client": "^6.28.0",
|
61
|
+
"@sanity/codegen": "3.76.1",
|
62
62
|
"@sanity/telemetry": "^0.7.7",
|
63
63
|
"@sanity/template-validator": "^2.4.0",
|
64
|
-
"@sanity/util": "3.
|
64
|
+
"@sanity/util": "3.76.1",
|
65
65
|
"chalk": "^4.1.2",
|
66
66
|
"debug": "^4.3.4",
|
67
67
|
"decompress": "^4.2.0",
|
@@ -75,13 +75,13 @@
|
|
75
75
|
"validate-npm-package-name": "^3.0.0"
|
76
76
|
},
|
77
77
|
"devDependencies": {
|
78
|
-
"@repo/package.config": "3.
|
79
|
-
"@repo/test-config": "3.
|
78
|
+
"@repo/package.config": "3.76.1",
|
79
|
+
"@repo/test-config": "3.76.1",
|
80
80
|
"@rexxars/gitconfiglocal": "^3.0.1",
|
81
81
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
82
82
|
"@sanity/eslint-config-studio": "^4.0.0",
|
83
83
|
"@sanity/generate-help-url": "^3.0.0",
|
84
|
-
"@sanity/types": "3.
|
84
|
+
"@sanity/types": "3.76.1",
|
85
85
|
"@types/babel__traverse": "^7.20.5",
|
86
86
|
"@types/configstore": "^5.0.1",
|
87
87
|
"@types/cpx": "^1.5.2",
|
@@ -133,5 +133,5 @@
|
|
133
133
|
"engines": {
|
134
134
|
"node": ">=18"
|
135
135
|
},
|
136
|
-
"gitHead": "
|
136
|
+
"gitHead": "9675bdd230a719cb11f667cf4549048c95fdb5f0"
|
137
137
|
}
|
@@ -130,7 +130,10 @@ export async function bootstrapLocalTemplate(
|
|
130
130
|
|
131
131
|
// ...and a CLI config (`sanity.cli.[ts|js]`)
|
132
132
|
const cliConfig = isCoreAppTemplate
|
133
|
-
? createCoreAppCliConfig({
|
133
|
+
? createCoreAppCliConfig({
|
134
|
+
appLocation: template.appLocation!,
|
135
|
+
organizationId: variables.organizationId,
|
136
|
+
})
|
134
137
|
: createCliConfig({
|
135
138
|
projectId: variables.projectId,
|
136
139
|
dataset: variables.dataset,
|
@@ -277,8 +277,9 @@ export default async function initSanity(
|
|
277
277
|
// skip project / dataset prompting
|
278
278
|
const isCoreAppTemplate = cliFlags.template ? determineCoreAppTemplate(cliFlags.template) : false // Default to false
|
279
279
|
|
280
|
-
// We're authenticated, now lets select or create a project
|
281
|
-
const {projectId, displayName, isFirstProject, datasetName, schemaUrl} =
|
280
|
+
// We're authenticated, now lets select or create a project (for studios) or org (for core apps)
|
281
|
+
const {projectId, displayName, isFirstProject, datasetName, schemaUrl, organizationId} =
|
282
|
+
await getProjectDetails()
|
282
283
|
|
283
284
|
const sluggedName = deburr(displayName.toLowerCase())
|
284
285
|
.replace(/\s+/g, '-')
|
@@ -715,6 +716,7 @@ export default async function initSanity(
|
|
715
716
|
displayName: string
|
716
717
|
isFirstProject: boolean
|
717
718
|
schemaUrl?: string
|
719
|
+
organizationId?: string
|
718
720
|
}> {
|
719
721
|
// If we're doing a quickstart, we don't need to prompt for project details
|
720
722
|
if (flags.quickstart) {
|
@@ -731,11 +733,17 @@ export default async function initSanity(
|
|
731
733
|
}
|
732
734
|
|
733
735
|
if (isCoreAppTemplate) {
|
736
|
+
const client = apiClient({requireUser: true, requireProject: false})
|
737
|
+
const organizations = await client.request({uri: '/organizations'})
|
738
|
+
|
739
|
+
const coreAppOrganizationId = await getOrganizationId(organizations)
|
740
|
+
|
734
741
|
return {
|
735
742
|
projectId: '',
|
736
743
|
displayName: '',
|
737
|
-
isFirstProject: false,
|
738
744
|
datasetName: '',
|
745
|
+
isFirstProject: false,
|
746
|
+
organizationId: coreAppOrganizationId,
|
739
747
|
}
|
740
748
|
}
|
741
749
|
|
@@ -1091,6 +1099,7 @@ export default async function initSanity(
|
|
1091
1099
|
dataset: datasetName,
|
1092
1100
|
projectId,
|
1093
1101
|
projectName: displayName || answers.projectName,
|
1102
|
+
organizationId,
|
1094
1103
|
}
|
1095
1104
|
|
1096
1105
|
if (remoteTemplateInfo) {
|
@@ -1230,12 +1239,12 @@ export default async function initSanity(
|
|
1230
1239
|
}
|
1231
1240
|
|
1232
1241
|
async function getOrganizationId(organizations: ProjectOrganization[]) {
|
1233
|
-
let
|
1242
|
+
let orgId = flags.organization
|
1234
1243
|
if (unattended) {
|
1235
|
-
return
|
1244
|
+
return orgId || undefined
|
1236
1245
|
}
|
1237
1246
|
|
1238
|
-
const shouldPrompt = organizations.length > 0 && !
|
1247
|
+
const shouldPrompt = organizations.length > 0 && !orgId
|
1239
1248
|
if (shouldPrompt) {
|
1240
1249
|
debug(`User has ${organizations.length} organization(s), checking attach access`)
|
1241
1250
|
const withGrant = await getOrganizationsWithAttachGrant(organizations)
|
@@ -1261,18 +1270,18 @@ export default async function initSanity(
|
|
1261
1270
|
})
|
1262
1271
|
|
1263
1272
|
if (chosenOrg && chosenOrg !== 'none') {
|
1264
|
-
|
1273
|
+
orgId = chosenOrg
|
1265
1274
|
}
|
1266
|
-
} else if (
|
1267
|
-
debug(`User has defined organization flag explicitly (%s)`,
|
1275
|
+
} else if (orgId) {
|
1276
|
+
debug(`User has defined organization flag explicitly (%s)`, orgId)
|
1268
1277
|
} else if (organizations.length === 0) {
|
1269
1278
|
debug('User has no organizations, skipping selection prompt')
|
1270
1279
|
}
|
1271
1280
|
|
1272
|
-
return
|
1281
|
+
return orgId || undefined
|
1273
1282
|
}
|
1274
1283
|
|
1275
|
-
async function hasProjectAttachGrant(
|
1284
|
+
async function hasProjectAttachGrant(orgId: string) {
|
1276
1285
|
const requiredGrantGroup = 'sanity.organization.projects'
|
1277
1286
|
const requiredGrant = 'attach'
|
1278
1287
|
|
@@ -1280,7 +1289,7 @@ export default async function initSanity(
|
|
1280
1289
|
.clone()
|
1281
1290
|
.config({apiVersion: 'v2021-06-07'})
|
1282
1291
|
|
1283
|
-
const grants = await client.request({uri: `organizations/${
|
1292
|
+
const grants = await client.request({uri: `organizations/${orgId}/grants`})
|
1284
1293
|
const group: {grants: {name: string}[]}[] = grants[requiredGrantGroup] || []
|
1285
1294
|
return group.some(
|
1286
1295
|
(resource) =>
|