@sanity/cli 3.91.1-next.23.8af6f8d288 → 3.91.1-next.24.3717582803

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli",
3
- "version": "3.91.1-next.23.8af6f8d288",
3
+ "version": "3.91.1-next.24.3717582803",
4
4
  "description": "Sanity CLI tool for managing Sanity installations, managing plugins, schemas and datasets",
5
5
  "keywords": [
6
6
  "sanity",
@@ -59,11 +59,11 @@
59
59
  "dependencies": {
60
60
  "@babel/traverse": "^7.23.5",
61
61
  "@sanity/client": "^7.4.1",
62
- "@sanity/codegen": "3.91.1-next.23.8af6f8d288",
62
+ "@sanity/codegen": "3.91.1-next.24.3717582803",
63
63
  "@sanity/runtime-cli": "^7.6.5",
64
64
  "@sanity/telemetry": "^0.8.0",
65
65
  "@sanity/template-validator": "^2.4.3",
66
- "@sanity/util": "3.91.1-next.23.8af6f8d288",
66
+ "@sanity/util": "3.91.1-next.24.3717582803",
67
67
  "chalk": "^4.1.2",
68
68
  "debug": "^4.3.4",
69
69
  "decompress": "^4.2.0",
@@ -83,7 +83,7 @@
83
83
  "@rollup/plugin-node-resolve": "^15.2.3",
84
84
  "@sanity/eslint-config-studio": "^4.0.0",
85
85
  "@sanity/generate-help-url": "^3.0.0",
86
- "@sanity/types": "3.91.1-next.23.8af6f8d288",
86
+ "@sanity/types": "3.91.1-next.24.3717582803",
87
87
  "@types/babel__traverse": "^7.20.5",
88
88
  "@types/configstore": "^5.0.1",
89
89
  "@types/cpx": "^1.5.2",
@@ -135,5 +135,5 @@
135
135
  "engines": {
136
136
  "node": ">=18"
137
137
  },
138
- "gitHead": "8af6f8d288d3ddc1d9a60f4b1430a33e48b18fdb"
138
+ "gitHead": "37175828033f8c6a7e3302fa5e39d8a19b35c11a"
139
139
  }
@@ -888,7 +888,7 @@ export default async function initSanity(
888
888
 
889
889
  return createProject(apiClient, {
890
890
  displayName: projectName,
891
- organizationId: await getOrganizationId(organizations),
891
+ organizationId: cliFlags.organization || (await getOrganizationId(organizations)),
892
892
  subscription: selectedPlan ? {planId: selectedPlan} : undefined,
893
893
  metadata: {coupon: intendedCoupon},
894
894
  }).then((response) => ({
@@ -924,7 +924,7 @@ export default async function initSanity(
924
924
  message: 'Your project name:',
925
925
  default: 'My Sanity Project',
926
926
  }),
927
- organizationId: await getOrganizationId(organizations),
927
+ organizationId: cliFlags.organization || (await getOrganizationId(organizations)),
928
928
  subscription: selectedPlan ? {planId: selectedPlan} : undefined,
929
929
  metadata: {coupon: intendedCoupon},
930
930
  }).then((response) => ({
@@ -1237,13 +1237,29 @@ export default async function initSanity(
1237
1237
  '`--project <id>` or `--create-project <name>` must be specified in unattended mode',
1238
1238
  )
1239
1239
  }
1240
+
1241
+ if (createProjectName && !cliFlags.organization) {
1242
+ throw new Error(
1243
+ '--create-project is not supported in unattended mode without an organization, please specify an organization with `--organization <id>`',
1244
+ )
1245
+ }
1240
1246
  }
1241
1247
 
1242
1248
  if (createProjectName) {
1243
1249
  debug('--create-project specified, creating a new project')
1250
+
1251
+ let orgForCreateProjectFlag = cliFlags.organization
1252
+ if (!orgForCreateProjectFlag) {
1253
+ debug('no organization specified, selecting one')
1254
+ const client = apiClient({requireUser: true, requireProject: false})
1255
+ const organizations = await client.request({uri: '/organizations'})
1256
+ orgForCreateProjectFlag = await getOrganizationId(organizations)
1257
+ }
1258
+
1259
+ debug('creating a new project')
1244
1260
  const createdProject = await createProject(apiClient, {
1245
1261
  displayName: createProjectName.trim(),
1246
- organizationId: cliFlags.organization || undefined,
1262
+ organizationId: orgForCreateProjectFlag,
1247
1263
  subscription: selectedPlan ? {planId: selectedPlan} : undefined,
1248
1264
  metadata: {coupon: intendedCoupon},
1249
1265
  })
@@ -1335,13 +1351,6 @@ export default async function initSanity(
1335
1351
  }
1336
1352
 
1337
1353
  async function getOrganizationId(organizations: ProjectOrganization[]) {
1338
- // In unattended mode, if the user hasn't specified an organization, sending null as
1339
- // organization ID to the API will create a new organization for the user with their
1340
- // user name. If they _have_ specified an organization, we'll use that.
1341
- if (unattended || flags.organization) {
1342
- return flags.organization || undefined
1343
- }
1344
-
1345
1354
  // If the user has no organizations, prompt them to create one with the same name as
1346
1355
  // their user, but allow them to customize it if they want
1347
1356
  if (organizations.length === 0) {