@sanity/cli 6.0.0-alpha.3 → 6.0.0-alpha.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/dist/actions/auth/login/{index.js → login.js} +1 -1
- package/dist/actions/auth/login/{index.js.map → login.js.map} +1 -1
- package/dist/actions/dev/startStudioDevServer.js +3 -8
- package/dist/actions/dev/startStudioDevServer.js.map +1 -1
- package/dist/actions/dev/types.d.ts +1 -3
- package/dist/actions/dev/types.js.map +1 -1
- package/dist/actions/documents/validate.d.ts +0 -2
- package/dist/actions/documents/validate.js +21 -1
- package/dist/actions/documents/validate.js.map +1 -1
- package/dist/actions/exec/execScript.js +1 -1
- package/dist/actions/exec/execScript.js.map +1 -1
- package/dist/actions/graphql/__tests__/getGraphQLAPIs.test.js +1 -1
- package/dist/actions/graphql/__tests__/getGraphQLAPIs.test.js.map +1 -1
- package/dist/actions/graphql/getGraphQLAPIs.js +1 -1
- package/dist/actions/graphql/getGraphQLAPIs.js.map +1 -1
- package/dist/actions/manifest/extractManifest.js +1 -4
- package/dist/actions/manifest/extractManifest.js.map +1 -1
- package/dist/actions/organizations/getOrganizationChoices.d.ts +6 -0
- package/dist/actions/organizations/getOrganizationChoices.js +23 -0
- package/dist/actions/organizations/getOrganizationChoices.js.map +1 -0
- package/dist/actions/organizations/getOrganizationsWithAttachGrantInfo.d.ts +2 -0
- package/dist/actions/organizations/getOrganizationsWithAttachGrantInfo.js +9 -0
- package/dist/actions/organizations/getOrganizationsWithAttachGrantInfo.js.map +1 -0
- package/dist/actions/organizations/hasProjectAttachGrant.d.ts +1 -0
- package/dist/actions/organizations/hasProjectAttachGrant.js +24 -0
- package/dist/actions/organizations/hasProjectAttachGrant.js.map +1 -0
- package/dist/actions/schema/deleteSchemaAction.d.ts +13 -5
- package/dist/actions/schema/deleteSchemaAction.js +12 -17
- package/dist/actions/schema/deleteSchemaAction.js.map +1 -1
- package/dist/actions/schema/deploySchemas.d.ts +15 -0
- package/dist/actions/schema/deploySchemas.js +98 -0
- package/dist/actions/schema/deploySchemas.js.map +1 -0
- package/dist/actions/schema/listSchemas.d.ts +12 -0
- package/dist/actions/schema/listSchemas.js +119 -0
- package/dist/actions/schema/listSchemas.js.map +1 -0
- package/dist/actions/schema/schemaStoreTypes.d.ts +0 -11
- package/dist/actions/schema/schemaStoreTypes.js.map +1 -1
- package/dist/actions/schema/utils/debug.d.ts +2 -0
- package/dist/actions/schema/utils/debug.js +5 -0
- package/dist/actions/schema/utils/debug.js.map +1 -0
- package/dist/actions/schema/utils/manifestExtractor.d.ts +3 -8
- package/dist/actions/schema/utils/manifestExtractor.js +12 -17
- package/dist/actions/schema/utils/manifestExtractor.js.map +1 -1
- package/dist/actions/schema/utils/manifestReader.d.ts +2 -9
- package/dist/actions/schema/utils/manifestReader.js +6 -12
- package/dist/actions/schema/utils/manifestReader.js.map +1 -1
- package/dist/actions/schema/utils/schemaStoreOutStrings.d.ts +0 -1
- package/dist/actions/schema/utils/schemaStoreOutStrings.js +1 -1
- package/dist/actions/schema/utils/schemaStoreOutStrings.js.map +1 -1
- package/dist/actions/schema/utils/schemaStoreValidation.d.ts +10 -62
- package/dist/actions/schema/utils/schemaStoreValidation.js +40 -127
- package/dist/actions/schema/utils/schemaStoreValidation.js.map +1 -1
- package/dist/actions/schema/utils/uniqByProjectIdDataset.d.ts +14 -0
- package/dist/actions/schema/utils/uniqByProjectIdDataset.js +9 -0
- package/dist/actions/schema/utils/uniqByProjectIdDataset.js.map +1 -0
- package/dist/actions/users/getMembersForProject.d.ts +1 -3
- package/dist/actions/users/getMembersForProject.js +6 -17
- package/dist/actions/users/getMembersForProject.js.map +1 -1
- package/dist/actions/users/types.d.ts +0 -11
- package/dist/actions/users/types.js.map +1 -1
- package/dist/commands/__tests__/debug.test.js +113 -220
- package/dist/commands/__tests__/debug.test.js.map +1 -1
- package/dist/commands/__tests__/deploy.test.js +325 -293
- package/dist/commands/__tests__/deploy.test.js.map +1 -1
- package/dist/commands/__tests__/dev.test.js +62 -19
- package/dist/commands/__tests__/dev.test.js.map +1 -1
- package/dist/commands/__tests__/init/init.authentication.test.js +73 -0
- package/dist/commands/__tests__/init/init.authentication.test.js.map +1 -0
- package/dist/commands/__tests__/init/init.create-new-project.test.js +195 -0
- package/dist/commands/__tests__/init/init.create-new-project.test.js.map +1 -0
- package/dist/commands/__tests__/init/init.plan.test.js +279 -0
- package/dist/commands/__tests__/init/init.plan.test.js.map +1 -0
- package/dist/commands/__tests__/init/init.setup.test.js +335 -0
- package/dist/commands/__tests__/init/init.setup.test.js.map +1 -0
- package/dist/commands/__tests__/install.test.js +46 -22
- package/dist/commands/__tests__/install.test.js.map +1 -1
- package/dist/commands/__tests__/logout.test.js +8 -5
- package/dist/commands/__tests__/logout.test.js.map +1 -1
- package/dist/commands/__tests__/manage.test.js +29 -24
- package/dist/commands/__tests__/manage.test.js.map +1 -1
- package/dist/commands/__tests__/migration.test.js +119 -0
- package/dist/commands/__tests__/migration.test.js.map +1 -0
- package/dist/commands/__tests__/versions.test.js +22 -14
- package/dist/commands/__tests__/versions.test.js.map +1 -1
- package/dist/commands/backup/__tests__/disable.test.js +72 -75
- package/dist/commands/backup/__tests__/disable.test.js.map +1 -1
- package/dist/commands/backup/__tests__/download.test.js +169 -80
- package/dist/commands/backup/__tests__/download.test.js.map +1 -1
- package/dist/commands/backup/__tests__/enable.test.js +109 -140
- package/dist/commands/backup/__tests__/enable.test.js.map +1 -1
- package/dist/commands/backup/__tests__/list.test.js +84 -75
- package/dist/commands/backup/__tests__/list.test.js.map +1 -1
- package/dist/commands/backup/disable.js +5 -11
- package/dist/commands/backup/disable.js.map +1 -1
- package/dist/commands/backup/enable.js +5 -11
- package/dist/commands/backup/enable.js.map +1 -1
- package/dist/commands/backup/list.js +7 -8
- package/dist/commands/backup/list.js.map +1 -1
- package/dist/commands/cors/__tests__/add.test.js +68 -38
- package/dist/commands/cors/__tests__/add.test.js.map +1 -1
- package/dist/commands/cors/__tests__/delete.test.js +52 -37
- package/dist/commands/cors/__tests__/delete.test.js.map +1 -1
- package/dist/commands/cors/__tests__/list.test.js +80 -57
- package/dist/commands/cors/__tests__/list.test.js.map +1 -1
- package/dist/commands/cors/add.js +5 -13
- package/dist/commands/cors/add.js.map +1 -1
- package/dist/commands/cors/delete.js +7 -15
- package/dist/commands/cors/delete.js.map +1 -1
- package/dist/commands/cors/list.js +2 -10
- package/dist/commands/cors/list.js.map +1 -1
- package/dist/commands/dataset/__tests__/copy.test.js +197 -89
- package/dist/commands/dataset/__tests__/copy.test.js.map +1 -1
- package/dist/commands/dataset/__tests__/create.test.js +147 -117
- package/dist/commands/dataset/__tests__/create.test.js.map +1 -1
- package/dist/commands/dataset/__tests__/delete.test.js +75 -68
- package/dist/commands/dataset/__tests__/delete.test.js.map +1 -1
- package/dist/commands/dataset/__tests__/export.test.js +123 -83
- package/dist/commands/dataset/__tests__/export.test.js.map +1 -1
- package/dist/commands/dataset/__tests__/import.test.js +2 -2
- package/dist/commands/dataset/__tests__/import.test.js.map +1 -1
- package/dist/commands/dataset/__tests__/list.test.js +107 -65
- package/dist/commands/dataset/__tests__/list.test.js.map +1 -1
- package/dist/commands/dataset/alias/__tests__/create.test.js +114 -74
- package/dist/commands/dataset/alias/__tests__/create.test.js.map +1 -1
- package/dist/commands/dataset/alias/__tests__/delete.test.js +40 -29
- package/dist/commands/dataset/alias/__tests__/delete.test.js.map +1 -1
- package/dist/commands/dataset/alias/__tests__/link.test.js +114 -74
- package/dist/commands/dataset/alias/__tests__/link.test.js.map +1 -1
- package/dist/commands/dataset/alias/__tests__/unlink.test.js +44 -29
- package/dist/commands/dataset/alias/__tests__/unlink.test.js.map +1 -1
- package/dist/commands/dataset/export.js +4 -4
- package/dist/commands/dataset/export.js.map +1 -1
- package/dist/commands/dataset/visibility/__tests__/get.test.js +48 -67
- package/dist/commands/dataset/visibility/__tests__/get.test.js.map +1 -1
- package/dist/commands/dataset/visibility/__tests__/set.test.js +76 -123
- package/dist/commands/dataset/visibility/__tests__/set.test.js.map +1 -1
- package/dist/commands/dev.js +0 -1
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/docs/__tests__/search.test.js +8 -7
- package/dist/commands/docs/__tests__/search.test.js.map +1 -1
- package/dist/commands/documents/__tests__/create.test.js +328 -265
- package/dist/commands/documents/__tests__/create.test.js.map +1 -1
- package/dist/commands/documents/__tests__/delete.test.js +119 -87
- package/dist/commands/documents/__tests__/delete.test.js.map +1 -1
- package/dist/commands/documents/__tests__/get.test.js +68 -95
- package/dist/commands/documents/__tests__/get.test.js.map +1 -1
- package/dist/commands/documents/__tests__/query.test.js +87 -192
- package/dist/commands/documents/__tests__/query.test.js.map +1 -1
- package/dist/commands/documents/__tests__/validate.test.js +52 -29
- package/dist/commands/documents/__tests__/validate.test.js.map +1 -1
- package/dist/commands/documents/create.d.ts +1 -0
- package/dist/commands/documents/create.js +10 -9
- package/dist/commands/documents/create.js.map +1 -1
- package/dist/commands/documents/delete.js +2 -3
- package/dist/commands/documents/delete.js.map +1 -1
- package/dist/commands/documents/get.js +2 -3
- package/dist/commands/documents/get.js.map +1 -1
- package/dist/commands/documents/query.js +2 -3
- package/dist/commands/documents/query.js.map +1 -1
- package/dist/commands/documents/validate.js +0 -20
- package/dist/commands/documents/validate.js.map +1 -1
- package/dist/commands/graphql/__tests__/list.test.js +57 -45
- package/dist/commands/graphql/__tests__/list.test.js.map +1 -1
- package/dist/commands/graphql/__tests__/undeploy.test.js +85 -59
- package/dist/commands/graphql/__tests__/undeploy.test.js.map +1 -1
- package/dist/commands/graphql/list.js +2 -2
- package/dist/commands/graphql/list.js.map +1 -1
- package/dist/commands/graphql/undeploy.js +4 -9
- package/dist/commands/graphql/undeploy.js.map +1 -1
- package/dist/commands/hook/__tests__/attempt.test.js +48 -33
- package/dist/commands/hook/__tests__/attempt.test.js.map +1 -1
- package/dist/commands/hook/__tests__/create.test.js +49 -51
- package/dist/commands/hook/__tests__/create.test.js.map +1 -1
- package/dist/commands/hook/__tests__/delete.test.js +43 -30
- package/dist/commands/hook/__tests__/delete.test.js.map +1 -1
- package/dist/commands/hook/__tests__/list.test.js +38 -31
- package/dist/commands/hook/__tests__/list.test.js.map +1 -1
- package/dist/commands/hook/__tests__/logs.test.js +68 -40
- package/dist/commands/hook/__tests__/logs.test.js.map +1 -1
- package/dist/commands/hook/create.js +2 -6
- package/dist/commands/hook/create.js.map +1 -1
- package/dist/commands/hook/delete.js +5 -17
- package/dist/commands/hook/delete.js.map +1 -1
- package/dist/commands/hook/list.js +2 -8
- package/dist/commands/hook/list.js.map +1 -1
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.js +151 -18
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/login.js +1 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/manifest/__tests__/extract.test.js +22 -13
- package/dist/commands/manifest/__tests__/extract.test.js.map +1 -1
- package/dist/commands/media/__tests__/create-aspect.test.js +41 -28
- package/dist/commands/media/__tests__/create-aspect.test.js.map +1 -1
- package/dist/commands/media/__tests__/delete-aspect.test.js +44 -35
- package/dist/commands/media/__tests__/delete-aspect.test.js.map +1 -1
- package/dist/commands/media/__tests__/deploy-aspect.test.js +67 -80
- package/dist/commands/media/__tests__/deploy-aspect.test.js.map +1 -1
- package/dist/commands/media/__tests__/export.test.js +365 -66
- package/dist/commands/media/__tests__/export.test.js.map +1 -1
- package/dist/commands/media/__tests__/import.test.js +171 -105
- package/dist/commands/media/__tests__/import.test.js.map +1 -1
- package/dist/commands/media/export.js +2 -2
- package/dist/commands/media/export.js.map +1 -1
- package/dist/commands/media/import.js +2 -2
- package/dist/commands/media/import.js.map +1 -1
- package/dist/commands/projects/__tests__/list.test.js +5 -4
- package/dist/commands/projects/__tests__/list.test.js.map +1 -1
- package/dist/commands/projects/list.js +2 -6
- package/dist/commands/projects/list.js.map +1 -1
- package/dist/commands/schema/__tests__/delete.test.js +396 -151
- package/dist/commands/schema/__tests__/delete.test.js.map +1 -1
- package/dist/commands/schema/__tests__/deploy.test.js +348 -0
- package/dist/commands/schema/__tests__/deploy.test.js.map +1 -0
- package/dist/commands/schema/__tests__/extract.test.js +19 -11
- package/dist/commands/schema/__tests__/extract.test.js.map +1 -1
- package/dist/commands/schema/__tests__/list.test.js +399 -0
- package/dist/commands/schema/__tests__/list.test.js.map +1 -0
- package/dist/commands/schema/__tests__/validate.test.js +27 -10
- package/dist/commands/schema/__tests__/validate.test.js.map +1 -1
- package/dist/commands/schema/delete.d.ts +1 -1
- package/dist/commands/schema/delete.js +20 -23
- package/dist/commands/schema/delete.js.map +1 -1
- package/dist/commands/schema/deploy.d.ts +16 -0
- package/dist/commands/schema/deploy.js +98 -0
- package/dist/commands/schema/deploy.js.map +1 -0
- package/dist/commands/schema/list.d.ts +15 -0
- package/dist/commands/schema/list.js +104 -0
- package/dist/commands/schema/list.js.map +1 -0
- package/dist/commands/telemetry/__tests__/disable.test.js +7 -5
- package/dist/commands/telemetry/__tests__/disable.test.js.map +1 -1
- package/dist/commands/telemetry/__tests__/enable.test.js +7 -5
- package/dist/commands/telemetry/__tests__/enable.test.js.map +1 -1
- package/dist/commands/telemetry/__tests__/status.test.js +7 -5
- package/dist/commands/telemetry/__tests__/status.test.js.map +1 -1
- package/dist/commands/tokens/__tests__/add.test.js +55 -40
- package/dist/commands/tokens/__tests__/add.test.js.map +1 -1
- package/dist/commands/tokens/__tests__/delete.test.js +72 -42
- package/dist/commands/tokens/__tests__/delete.test.js.map +1 -1
- package/dist/commands/tokens/__tests__/list.test.js +87 -60
- package/dist/commands/tokens/__tests__/list.test.js.map +1 -1
- package/dist/commands/tokens/add.js +3 -5
- package/dist/commands/tokens/add.js.map +1 -1
- package/dist/commands/users/__tests__/invite.test.js +100 -79
- package/dist/commands/users/__tests__/invite.test.js.map +1 -1
- package/dist/commands/users/__tests__/list.test.js +186 -180
- package/dist/commands/users/__tests__/list.test.js.map +1 -1
- package/dist/commands/users/invite.js +6 -17
- package/dist/commands/users/invite.js.map +1 -1
- package/dist/commands/users/list.js +4 -7
- package/dist/commands/users/list.js.map +1 -1
- package/dist/config/createCliConfig.d.ts +4 -4
- package/dist/services/backup.d.ts +8 -0
- package/dist/services/backup.js +19 -0
- package/dist/services/backup.js.map +1 -1
- package/dist/services/cors.d.ts +23 -0
- package/dist/services/cors.js +38 -0
- package/dist/services/cors.js.map +1 -0
- package/dist/services/graphql.d.ts +7 -0
- package/dist/services/graphql.js +11 -0
- package/dist/services/graphql.js.map +1 -1
- package/dist/services/hooks.d.ts +2 -0
- package/dist/services/hooks.js +19 -0
- package/dist/services/hooks.js.map +1 -1
- package/dist/services/organizations.d.ts +40 -0
- package/dist/services/organizations.js +41 -0
- package/dist/services/organizations.js.map +1 -0
- package/dist/services/projects.d.ts +31 -0
- package/dist/services/projects.js +71 -1
- package/dist/services/projects.js.map +1 -1
- package/dist/services/schemas.d.ts +4 -0
- package/dist/services/schemas.js +40 -0
- package/dist/services/schemas.js.map +1 -0
- package/dist/services/user.d.ts +10 -0
- package/dist/services/user.js +24 -0
- package/dist/services/user.js.map +1 -0
- package/dist/util/__tests__/getCliVersion.test.js +2 -2
- package/dist/util/__tests__/getCliVersion.test.js.map +1 -1
- package/dist/util/errorMessages.d.ts +1 -0
- package/dist/util/errorMessages.js +1 -0
- package/dist/util/errorMessages.js.map +1 -1
- package/dist/util/getCliVersion.js +1 -1
- package/dist/util/getCliVersion.js.map +1 -1
- package/dist/util/readPackageJson.d.ts +1 -15
- package/dist/util/readPackageJson.js +1 -1
- package/dist/util/readPackageJson.js.map +1 -1
- package/dist/util/uniqBy.d.ts +1 -0
- package/dist/util/uniqBy.js +14 -0
- package/dist/util/uniqBy.js.map +1 -0
- package/oclif.config.js +6 -1
- package/oclif.manifest.json +152 -158
- package/package.json +30 -31
- package/dist/actions/cors/constants.d.ts +0 -1
- package/dist/actions/cors/constants.js +0 -3
- package/dist/actions/cors/constants.js.map +0 -1
- package/dist/actions/cors/types.d.ts +0 -9
- package/dist/actions/cors/types.js +0 -3
- package/dist/actions/cors/types.js.map +0 -1
- package/dist/actions/migration/getMigrationRootDirectory.d.ts +0 -2
- package/dist/actions/migration/getMigrationRootDirectory.js +0 -14
- package/dist/actions/migration/getMigrationRootDirectory.js.map +0 -1
- package/dist/actions/migration/resolveMigrations.d.ts +0 -19
- package/dist/actions/migration/resolveMigrations.js +0 -43
- package/dist/actions/migration/resolveMigrations.js.map +0 -1
- package/dist/actions/migration/templates/__tests__/minimalAdvanced.test.js +0 -65
- package/dist/actions/migration/templates/__tests__/minimalAdvanced.test.js.map +0 -1
- package/dist/actions/migration/templates/__tests__/minimalSimple.test.js +0 -145
- package/dist/actions/migration/templates/__tests__/minimalSimple.test.js.map +0 -1
- package/dist/actions/migration/templates/__tests__/renameField.test.js +0 -63
- package/dist/actions/migration/templates/__tests__/renameField.test.js.map +0 -1
- package/dist/actions/migration/templates/__tests__/renameType.test.js +0 -61
- package/dist/actions/migration/templates/__tests__/renameType.test.js.map +0 -1
- package/dist/actions/migration/templates/__tests__/stringToPTE.test.js +0 -87
- package/dist/actions/migration/templates/__tests__/stringToPTE.test.js.map +0 -1
- package/dist/actions/migration/templates/index.d.ts +0 -5
- package/dist/actions/migration/templates/index.js +0 -7
- package/dist/actions/migration/templates/index.js.map +0 -1
- package/dist/actions/migration/templates/minimalAdvanced.d.ts +0 -4
- package/dist/actions/migration/templates/minimalAdvanced.js +0 -21
- package/dist/actions/migration/templates/minimalAdvanced.js.map +0 -1
- package/dist/actions/migration/templates/minimalSimple.d.ts +0 -4
- package/dist/actions/migration/templates/minimalSimple.js +0 -61
- package/dist/actions/migration/templates/minimalSimple.js.map +0 -1
- package/dist/actions/migration/templates/renameField.d.ts +0 -4
- package/dist/actions/migration/templates/renameField.js +0 -20
- package/dist/actions/migration/templates/renameField.js.map +0 -1
- package/dist/actions/migration/templates/renameType.d.ts +0 -4
- package/dist/actions/migration/templates/renameType.js +0 -19
- package/dist/actions/migration/templates/renameType.js.map +0 -1
- package/dist/actions/migration/templates/stringToPTE.d.ts +0 -4
- package/dist/actions/migration/templates/stringToPTE.js +0 -32
- package/dist/actions/migration/templates/stringToPTE.js.map +0 -1
- package/dist/actions/schema/__tests__/deleteSchemaAction.test.js +0 -294
- package/dist/actions/schema/__tests__/deleteSchemaAction.test.js.map +0 -1
- package/dist/actions/schema/schemaStoreConstants.d.ts +0 -1
- package/dist/actions/schema/schemaStoreConstants.js +0 -4
- package/dist/actions/schema/schemaStoreConstants.js.map +0 -1
- package/dist/actions/schema/utils/schemaActionHelpers.d.ts +0 -1
- package/dist/actions/schema/utils/schemaActionHelpers.js +0 -5
- package/dist/actions/schema/utils/schemaActionHelpers.js.map +0 -1
- package/dist/actions/schema/utils/schemaApiClient.d.ts +0 -6
- package/dist/actions/schema/utils/schemaApiClient.js +0 -17
- package/dist/actions/schema/utils/schemaApiClient.js.map +0 -1
- package/dist/actions/users/apiVersion.d.ts +0 -6
- package/dist/actions/users/apiVersion.js +0 -7
- package/dist/actions/users/apiVersion.js.map +0 -1
- package/dist/commands/__tests__/init.test.js +0 -411
- package/dist/commands/__tests__/init.test.js.map +0 -1
- package/dist/commands/migration/__tests__/create.test.js +0 -296
- package/dist/commands/migration/__tests__/create.test.js.map +0 -1
- package/dist/commands/migration/__tests__/list.test.js +0 -166
- package/dist/commands/migration/__tests__/list.test.js.map +0 -1
- package/dist/commands/migration/__tests__/run.test.js +0 -481
- package/dist/commands/migration/__tests__/run.test.js.map +0 -1
- package/dist/commands/migration/create.d.ts +0 -17
- package/dist/commands/migration/create.js +0 -143
- package/dist/commands/migration/create.js.map +0 -1
- package/dist/commands/migration/list.d.ts +0 -9
- package/dist/commands/migration/list.js +0 -61
- package/dist/commands/migration/list.js.map +0 -1
- package/dist/commands/migration/run.d.ts +0 -26
- package/dist/commands/migration/run.js +0 -271
- package/dist/commands/migration/run.js.map +0 -1
- package/dist/util/migration/constants.d.ts +0 -3
- package/dist/util/migration/constants.js +0 -10
- package/dist/util/migration/constants.js.map +0 -1
- package/dist/util/migration/ensureApiVersionFormat.d.ts +0 -9
- package/dist/util/migration/ensureApiVersionFormat.js +0 -16
- package/dist/util/migration/ensureApiVersionFormat.js.map +0 -1
- package/dist/util/migration/prettyMutationFormatter.d.ts +0 -8
- package/dist/util/migration/prettyMutationFormatter.js +0 -141
- package/dist/util/migration/prettyMutationFormatter.js.map +0 -1
- package/dist/utils/migration/resolveMigrationScript.d.ts +0 -44
- package/dist/utils/migration/resolveMigrationScript.js +0 -74
- package/dist/utils/migration/resolveMigrationScript.js.map +0 -1
- /package/dist/actions/auth/login/{index.d.ts → login.d.ts} +0 -0
|
@@ -1,28 +1,36 @@
|
|
|
1
1
|
import { runCommand } from '@oclif/test';
|
|
2
|
-
import {
|
|
2
|
+
import { getCliToken, getConfig } from '@sanity/cli-core';
|
|
3
3
|
import { mockApi, testCommand } from '@sanity/cli-test';
|
|
4
4
|
import nock from 'nock';
|
|
5
5
|
import { afterEach, describe, expect, test, vi } from 'vitest';
|
|
6
6
|
import { findSanityModulesVersions } from '../../actions/versions/findSanityModulesVersions.js';
|
|
7
7
|
import { Debug } from '../debug.js';
|
|
8
|
-
|
|
9
|
-
vi.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
vi.
|
|
8
|
+
vi.mock('@sanity/cli-core', async ()=>{
|
|
9
|
+
const actual = await vi.importActual('@sanity/cli-core');
|
|
10
|
+
return {
|
|
11
|
+
...actual,
|
|
12
|
+
getCliToken: vi.fn(),
|
|
13
13
|
getConfig: vi.fn()
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
findProjectRoot: vi.fn()
|
|
17
|
-
}));
|
|
18
|
-
// Mock the CLI config function like in manage.test.ts
|
|
19
|
-
vi.mock('../../../../cli-core/src/config/cli/getCliConfig.js', ()=>({
|
|
20
|
-
getCliConfig: vi.fn()
|
|
21
|
-
}));
|
|
22
|
-
// Mock version-related functions
|
|
14
|
+
};
|
|
15
|
+
});
|
|
23
16
|
vi.mock('../../actions/versions/findSanityModulesVersions.js', ()=>({
|
|
24
17
|
findSanityModulesVersions: vi.fn()
|
|
25
18
|
}));
|
|
19
|
+
const defaultProjectRoot = {
|
|
20
|
+
directory: '/test/project',
|
|
21
|
+
path: '/test/project/sanity.cli.ts',
|
|
22
|
+
type: 'studio'
|
|
23
|
+
};
|
|
24
|
+
const defaultCliConfig = {
|
|
25
|
+
api: {
|
|
26
|
+
projectId: 'project123'
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const defaultMocks = {
|
|
30
|
+
cliConfig: defaultCliConfig,
|
|
31
|
+
projectRoot: defaultProjectRoot,
|
|
32
|
+
token: 'mock-auth-token'
|
|
33
|
+
};
|
|
26
34
|
afterEach(()=>{
|
|
27
35
|
vi.clearAllMocks();
|
|
28
36
|
const pending = nock.pendingMocks();
|
|
@@ -53,7 +61,6 @@ describe('#debug', ()=>{
|
|
|
53
61
|
`);
|
|
54
62
|
});
|
|
55
63
|
test('shows debug information with authentication and config details', async ()=>{
|
|
56
|
-
// Mock authentication
|
|
57
64
|
vi.mocked(getCliToken).mockResolvedValue('mock-auth-token');
|
|
58
65
|
vi.mocked(getConfig).mockImplementation(async (key)=>{
|
|
59
66
|
if (key === 'authToken') return 'mock-auth-token';
|
|
@@ -66,19 +73,6 @@ describe('#debug', ()=>{
|
|
|
66
73
|
};
|
|
67
74
|
return undefined;
|
|
68
75
|
});
|
|
69
|
-
// Mock project configuration
|
|
70
|
-
vi.mocked(findProjectRoot).mockResolvedValue({
|
|
71
|
-
directory: '/test/project',
|
|
72
|
-
path: '/test/project/sanity.cli.ts',
|
|
73
|
-
type: 'studio'
|
|
74
|
-
});
|
|
75
|
-
vi.mocked(getCliConfig).mockResolvedValue({
|
|
76
|
-
api: {
|
|
77
|
-
dataset: 'production',
|
|
78
|
-
projectId: 'project123'
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
// Mock version info with some packages
|
|
82
76
|
vi.mocked(findSanityModulesVersions).mockResolvedValue([
|
|
83
77
|
{
|
|
84
78
|
declared: '^3.0.0',
|
|
@@ -99,8 +93,17 @@ describe('#debug', ()=>{
|
|
|
99
93
|
needsUpdate: true
|
|
100
94
|
}
|
|
101
95
|
]);
|
|
102
|
-
const { stdout } = await testCommand(Debug, []
|
|
103
|
-
|
|
96
|
+
const { stdout } = await testCommand(Debug, [], {
|
|
97
|
+
mocks: {
|
|
98
|
+
...defaultMocks,
|
|
99
|
+
cliConfig: {
|
|
100
|
+
api: {
|
|
101
|
+
dataset: 'production',
|
|
102
|
+
projectId: 'project123'
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
104
107
|
expect(stdout).toContain('User:');
|
|
105
108
|
expect(stdout).toContain('Authentication:');
|
|
106
109
|
expect(stdout).toContain('<redacted>');
|
|
@@ -112,82 +115,61 @@ describe('#debug', ()=>{
|
|
|
112
115
|
expect(stdout).toContain('(latest: 3.1.0)');
|
|
113
116
|
});
|
|
114
117
|
test('shows redacted auth token by default', async ()=>{
|
|
115
|
-
// Mock basic authentication
|
|
116
118
|
vi.mocked(getCliToken).mockResolvedValue('mock-auth-token');
|
|
117
119
|
vi.mocked(getConfig).mockImplementation(async (key)=>{
|
|
118
120
|
if (key === 'authToken') return 'mock-auth-token';
|
|
119
121
|
return undefined;
|
|
120
122
|
});
|
|
121
|
-
// Mock minimal project setup
|
|
122
|
-
vi.mocked(findProjectRoot).mockResolvedValue({
|
|
123
|
-
directory: '/test/project',
|
|
124
|
-
path: '/test/project/sanity.cli.ts',
|
|
125
|
-
type: 'studio'
|
|
126
|
-
});
|
|
127
|
-
vi.mocked(getCliConfig).mockResolvedValue({
|
|
128
|
-
api: {
|
|
129
|
-
projectId: 'project123'
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
123
|
vi.mocked(findSanityModulesVersions).mockResolvedValue([]);
|
|
133
|
-
const { stdout } = await testCommand(Debug, []
|
|
124
|
+
const { stdout } = await testCommand(Debug, [], {
|
|
125
|
+
mocks: defaultMocks
|
|
126
|
+
});
|
|
134
127
|
expect(stdout).toContain('<redacted>');
|
|
135
128
|
expect(stdout).toContain('(run with --secrets to reveal token)');
|
|
136
129
|
expect(stdout).not.toContain('mock-auth-token');
|
|
137
130
|
});
|
|
138
131
|
test('shows actual auth token with --secrets flag', async ()=>{
|
|
139
|
-
// Mock authentication with specific token
|
|
140
132
|
vi.mocked(getCliToken).mockResolvedValue('secret-token-12345');
|
|
141
133
|
vi.mocked(getConfig).mockImplementation(async (key)=>{
|
|
142
134
|
if (key === 'authToken') return 'secret-token-12345';
|
|
143
135
|
return undefined;
|
|
144
136
|
});
|
|
145
|
-
// Mock minimal project setup
|
|
146
|
-
vi.mocked(findProjectRoot).mockResolvedValue({
|
|
147
|
-
directory: '/test/project',
|
|
148
|
-
path: '/test/project/sanity.cli.ts',
|
|
149
|
-
type: 'studio'
|
|
150
|
-
});
|
|
151
|
-
vi.mocked(getCliConfig).mockResolvedValue({
|
|
152
|
-
api: {
|
|
153
|
-
projectId: 'project123'
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
137
|
vi.mocked(findSanityModulesVersions).mockResolvedValue([]);
|
|
157
138
|
const { stdout } = await testCommand(Debug, [
|
|
158
139
|
'--secrets'
|
|
159
|
-
]
|
|
140
|
+
], {
|
|
141
|
+
mocks: {
|
|
142
|
+
...defaultMocks,
|
|
143
|
+
token: 'secret-token-12345'
|
|
144
|
+
}
|
|
145
|
+
});
|
|
160
146
|
expect(stdout).toContain('secret-token-12345');
|
|
161
147
|
expect(stdout).not.toContain('<redacted>');
|
|
162
148
|
expect(stdout).not.toContain('(run with --secrets to reveal token)');
|
|
163
149
|
});
|
|
164
150
|
test('handles unauthenticated user', async ()=>{
|
|
165
|
-
// Mock no authentication
|
|
166
151
|
vi.mocked(getCliToken).mockResolvedValue(undefined);
|
|
167
152
|
vi.mocked(getConfig).mockImplementation(async ()=>undefined);
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
153
|
+
vi.mocked(findSanityModulesVersions).mockResolvedValue([]);
|
|
154
|
+
const { error, stdout } = await testCommand(Debug, [], {
|
|
155
|
+
mocks: {
|
|
156
|
+
...defaultMocks,
|
|
157
|
+
token: undefined
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
// When not authenticated, either the command errors or shows "Not logged in" message
|
|
161
|
+
if (error) {
|
|
162
|
+
expect(error.message).toContain('Failed to gather debug information');
|
|
163
|
+
} else {
|
|
164
|
+
expect(stdout).toContain('Not logged in');
|
|
165
|
+
}
|
|
171
166
|
});
|
|
172
167
|
test('shows package versions with update information', async ()=>{
|
|
173
|
-
// Mock basic authentication
|
|
174
168
|
vi.mocked(getCliToken).mockResolvedValue('mock-auth-token');
|
|
175
169
|
vi.mocked(getConfig).mockImplementation(async (key)=>{
|
|
176
170
|
if (key === 'authToken') return 'mock-auth-token';
|
|
177
171
|
return undefined;
|
|
178
172
|
});
|
|
179
|
-
// Mock project setup
|
|
180
|
-
vi.mocked(findProjectRoot).mockResolvedValue({
|
|
181
|
-
directory: '/test/project',
|
|
182
|
-
path: '/test/project/sanity.cli.ts',
|
|
183
|
-
type: 'studio'
|
|
184
|
-
});
|
|
185
|
-
vi.mocked(getCliConfig).mockResolvedValue({
|
|
186
|
-
api: {
|
|
187
|
-
projectId: 'project123'
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
// Mock version info with mixed update statuses
|
|
191
173
|
vi.mocked(findSanityModulesVersions).mockResolvedValue([
|
|
192
174
|
{
|
|
193
175
|
declared: '^3.0.0',
|
|
@@ -217,7 +199,9 @@ describe('#debug', ()=>{
|
|
|
217
199
|
needsUpdate: true
|
|
218
200
|
}
|
|
219
201
|
]);
|
|
220
|
-
const { stdout } = await testCommand(Debug, []
|
|
202
|
+
const { stdout } = await testCommand(Debug, [], {
|
|
203
|
+
mocks: defaultMocks
|
|
204
|
+
});
|
|
221
205
|
expect(stdout).toContain('Package versions:');
|
|
222
206
|
expect(stdout).toContain('sanity');
|
|
223
207
|
expect(stdout).toContain('3.0.0');
|
|
@@ -227,7 +211,9 @@ describe('#debug', ()=>{
|
|
|
227
211
|
});
|
|
228
212
|
test('handles errors gracefully', async ()=>{
|
|
229
213
|
vi.mocked(getCliToken).mockRejectedValue(new Error('Auth system unavailable'));
|
|
230
|
-
const { error } = await testCommand(Debug, []
|
|
214
|
+
const { error } = await testCommand(Debug, [], {
|
|
215
|
+
mocks: defaultMocks
|
|
216
|
+
});
|
|
231
217
|
expect(error?.message).toContain('Failed to gather debug information');
|
|
232
218
|
expect(error?.message).toContain('Auth system unavailable');
|
|
233
219
|
});
|
|
@@ -238,17 +224,6 @@ describe('#debug', ()=>{
|
|
|
238
224
|
if (key === 'authToken') return 'mock-auth-token';
|
|
239
225
|
return undefined;
|
|
240
226
|
});
|
|
241
|
-
// Mock project configuration but no project info from API
|
|
242
|
-
vi.mocked(findProjectRoot).mockResolvedValue({
|
|
243
|
-
directory: '/test/project',
|
|
244
|
-
path: '/test/project/sanity.cli.ts',
|
|
245
|
-
type: 'studio'
|
|
246
|
-
});
|
|
247
|
-
vi.mocked(getCliConfig).mockResolvedValue({
|
|
248
|
-
api: {
|
|
249
|
-
projectId: 'project123'
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
227
|
vi.mocked(findSanityModulesVersions).mockResolvedValue([]);
|
|
253
228
|
// Mock the /me API endpoint to return user info
|
|
254
229
|
mockApi({
|
|
@@ -264,7 +239,9 @@ describe('#debug', ()=>{
|
|
|
264
239
|
apiVersion: 'v2025-08-06',
|
|
265
240
|
uri: '/projects/project123'
|
|
266
241
|
}).reply(404);
|
|
267
|
-
const { stdout } = await testCommand(Debug, []
|
|
242
|
+
const { stdout } = await testCommand(Debug, [], {
|
|
243
|
+
mocks: defaultMocks
|
|
244
|
+
});
|
|
268
245
|
expect(stdout).toContain('User:');
|
|
269
246
|
expect(stdout).toContain("Email: 'test@example.com'");
|
|
270
247
|
expect(stdout).toContain("ID: 'user123'");
|
|
@@ -277,17 +254,6 @@ describe('#debug', ()=>{
|
|
|
277
254
|
if (key === 'authToken') return 'mock-auth-token';
|
|
278
255
|
return undefined;
|
|
279
256
|
});
|
|
280
|
-
// Mock project configuration
|
|
281
|
-
vi.mocked(findProjectRoot).mockResolvedValue({
|
|
282
|
-
directory: '/test/project',
|
|
283
|
-
path: '/test/project/sanity.cli.ts',
|
|
284
|
-
type: 'studio'
|
|
285
|
-
});
|
|
286
|
-
vi.mocked(getCliConfig).mockResolvedValue({
|
|
287
|
-
api: {
|
|
288
|
-
projectId: 'project123'
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
257
|
vi.mocked(findSanityModulesVersions).mockResolvedValue([]);
|
|
292
258
|
// Mock the /me API endpoint to return user info
|
|
293
259
|
mockApi({
|
|
@@ -317,7 +283,9 @@ describe('#debug', ()=>{
|
|
|
317
283
|
],
|
|
318
284
|
studioHost: 'test-project'
|
|
319
285
|
});
|
|
320
|
-
const { stdout } = await testCommand(Debug, []
|
|
286
|
+
const { stdout } = await testCommand(Debug, [], {
|
|
287
|
+
mocks: defaultMocks
|
|
288
|
+
});
|
|
321
289
|
expect(stdout).toContain('Project:');
|
|
322
290
|
expect(stdout).toContain("Display name: 'Test Project'");
|
|
323
291
|
expect(stdout).toContain("ID: 'project123'");
|
|
@@ -327,21 +295,20 @@ describe('#debug', ()=>{
|
|
|
327
295
|
// Mock no authentication
|
|
328
296
|
vi.mocked(getCliToken).mockResolvedValue(undefined);
|
|
329
297
|
vi.mocked(getConfig).mockImplementation(async ()=>undefined);
|
|
330
|
-
// Mock project configuration
|
|
331
|
-
vi.mocked(findProjectRoot).mockResolvedValue({
|
|
332
|
-
directory: '/test/project',
|
|
333
|
-
path: '/test/project/sanity.cli.ts',
|
|
334
|
-
type: 'studio'
|
|
335
|
-
});
|
|
336
|
-
vi.mocked(getCliConfig).mockResolvedValue({
|
|
337
|
-
api: {
|
|
338
|
-
projectId: 'project123'
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
298
|
vi.mocked(findSanityModulesVersions).mockResolvedValue([]);
|
|
342
299
|
// Command should fail when no auth token is present since it requires authentication
|
|
343
|
-
const { error } = await testCommand(Debug, []
|
|
344
|
-
|
|
300
|
+
const { error, stdout } = await testCommand(Debug, [], {
|
|
301
|
+
mocks: {
|
|
302
|
+
...defaultMocks,
|
|
303
|
+
token: undefined
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
// When not authenticated, either the command errors or shows "Not logged in" message
|
|
307
|
+
if (error) {
|
|
308
|
+
expect(error.message).toContain('Failed to gather debug information');
|
|
309
|
+
} else {
|
|
310
|
+
expect(stdout).toContain('Not logged in');
|
|
311
|
+
}
|
|
345
312
|
});
|
|
346
313
|
test('handles case when no project config is present', async ()=>{
|
|
347
314
|
// Mock authentication
|
|
@@ -350,16 +317,6 @@ describe('#debug', ()=>{
|
|
|
350
317
|
if (key === 'authToken') return 'mock-auth-token';
|
|
351
318
|
return undefined;
|
|
352
319
|
});
|
|
353
|
-
// Mock project configuration with no projectId (invalid config)
|
|
354
|
-
vi.mocked(findProjectRoot).mockResolvedValue({
|
|
355
|
-
directory: '/test/project',
|
|
356
|
-
path: '/test/project/sanity.cli.ts',
|
|
357
|
-
type: 'studio'
|
|
358
|
-
});
|
|
359
|
-
vi.mocked(getCliConfig).mockResolvedValue({
|
|
360
|
-
api: {
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
320
|
vi.mocked(findSanityModulesVersions).mockResolvedValue([]);
|
|
364
321
|
// Mock the /me API endpoint to return user info
|
|
365
322
|
mockApi({
|
|
@@ -371,7 +328,15 @@ describe('#debug', ()=>{
|
|
|
371
328
|
name: 'Test User'
|
|
372
329
|
});
|
|
373
330
|
// No project API mock needed since no valid projectId
|
|
374
|
-
const { stdout } = await testCommand(Debug, []
|
|
331
|
+
const { stdout } = await testCommand(Debug, [], {
|
|
332
|
+
mocks: {
|
|
333
|
+
...defaultMocks,
|
|
334
|
+
cliConfig: {
|
|
335
|
+
api: {
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
});
|
|
375
340
|
expect(stdout).toContain('Global config');
|
|
376
341
|
expect(stdout).toContain('Project config');
|
|
377
342
|
expect(stdout).toContain('Missing required "api.projectId" key');
|
|
@@ -383,17 +348,6 @@ describe('#debug', ()=>{
|
|
|
383
348
|
if (key === 'authToken') return 'mock-auth-token';
|
|
384
349
|
return undefined;
|
|
385
350
|
});
|
|
386
|
-
// Mock project configuration
|
|
387
|
-
vi.mocked(findProjectRoot).mockResolvedValue({
|
|
388
|
-
directory: '/test/project',
|
|
389
|
-
path: '/test/project/sanity.cli.ts',
|
|
390
|
-
type: 'studio'
|
|
391
|
-
});
|
|
392
|
-
vi.mocked(getCliConfig).mockResolvedValue({
|
|
393
|
-
api: {
|
|
394
|
-
projectId: 'project123'
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
351
|
// Mock findSanityModulesVersions to return empty array (no versions)
|
|
398
352
|
vi.mocked(findSanityModulesVersions).mockResolvedValue([]);
|
|
399
353
|
// Mock the /me API endpoint to return user info
|
|
@@ -424,26 +378,19 @@ describe('#debug', ()=>{
|
|
|
424
378
|
],
|
|
425
379
|
studioHost: 'test-project'
|
|
426
380
|
});
|
|
427
|
-
const { stdout } = await testCommand(Debug, []
|
|
381
|
+
const { stdout } = await testCommand(Debug, [], {
|
|
382
|
+
mocks: defaultMocks
|
|
383
|
+
});
|
|
428
384
|
expect(stdout).toContain('Global config');
|
|
429
385
|
expect(stdout).toContain('Package versions:');
|
|
430
386
|
// Should show the heading but no packages since the array is empty
|
|
431
387
|
});
|
|
432
388
|
test('handles error case with unknown error type', async ()=>{
|
|
433
|
-
// Mock project configuration
|
|
434
|
-
vi.mocked(findProjectRoot).mockResolvedValue({
|
|
435
|
-
directory: '/test/project',
|
|
436
|
-
path: '/test/project/sanity.cli.ts',
|
|
437
|
-
type: 'studio'
|
|
438
|
-
});
|
|
439
|
-
vi.mocked(getCliConfig).mockResolvedValue({
|
|
440
|
-
api: {
|
|
441
|
-
projectId: 'project123'
|
|
442
|
-
}
|
|
443
|
-
});
|
|
444
389
|
// Mock getCliToken to throw a non-Error object to trigger unknown error path
|
|
445
390
|
vi.mocked(getCliToken).mockRejectedValue('string error');
|
|
446
|
-
const { error } = await testCommand(Debug, []
|
|
391
|
+
const { error } = await testCommand(Debug, [], {
|
|
392
|
+
mocks: defaultMocks
|
|
393
|
+
});
|
|
447
394
|
expect(error).toBeTruthy();
|
|
448
395
|
expect(error?.message).toContain('Failed to gather debug information');
|
|
449
396
|
expect(error?.message).toContain('Unknown error');
|
|
@@ -453,17 +400,6 @@ describe('#debug', ()=>{
|
|
|
453
400
|
vi.mocked(getCliToken).mockResolvedValue('mock-auth-token');
|
|
454
401
|
// Mock getConfig to throw an error
|
|
455
402
|
vi.mocked(getConfig).mockRejectedValue(new Error('Config access error'));
|
|
456
|
-
// Mock project configuration
|
|
457
|
-
vi.mocked(findProjectRoot).mockResolvedValue({
|
|
458
|
-
directory: '/test/project',
|
|
459
|
-
path: '/test/project/sanity.cli.ts',
|
|
460
|
-
type: 'studio'
|
|
461
|
-
});
|
|
462
|
-
vi.mocked(getCliConfig).mockResolvedValue({
|
|
463
|
-
api: {
|
|
464
|
-
projectId: 'project123'
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
403
|
vi.mocked(findSanityModulesVersions).mockResolvedValue([]);
|
|
468
404
|
// Mock the /me API endpoint to return user info
|
|
469
405
|
mockApi({
|
|
@@ -484,7 +420,9 @@ describe('#debug', ()=>{
|
|
|
484
420
|
members: [],
|
|
485
421
|
studioHost: 'test-project'
|
|
486
422
|
});
|
|
487
|
-
const { stdout } = await testCommand(Debug, []
|
|
423
|
+
const { stdout } = await testCommand(Debug, [], {
|
|
424
|
+
mocks: defaultMocks
|
|
425
|
+
});
|
|
488
426
|
// Should continue to work despite global config error
|
|
489
427
|
expect(stdout).toContain('Global config');
|
|
490
428
|
expect(stdout).toContain('User:');
|
|
@@ -497,17 +435,6 @@ describe('#debug', ()=>{
|
|
|
497
435
|
if (key === 'authToken') return 'mock-auth-token';
|
|
498
436
|
return undefined;
|
|
499
437
|
});
|
|
500
|
-
// Mock project configuration
|
|
501
|
-
vi.mocked(findProjectRoot).mockResolvedValue({
|
|
502
|
-
directory: '/test/project',
|
|
503
|
-
path: '/test/project/sanity.cli.ts',
|
|
504
|
-
type: 'studio'
|
|
505
|
-
});
|
|
506
|
-
vi.mocked(getCliConfig).mockResolvedValue({
|
|
507
|
-
api: {
|
|
508
|
-
projectId: 'project123'
|
|
509
|
-
}
|
|
510
|
-
});
|
|
511
438
|
vi.mocked(findSanityModulesVersions).mockResolvedValue([]);
|
|
512
439
|
// Mock the /me API endpoint to return an error
|
|
513
440
|
mockApi({
|
|
@@ -516,7 +443,9 @@ describe('#debug', ()=>{
|
|
|
516
443
|
}).reply(500, {
|
|
517
444
|
error: 'Internal server error'
|
|
518
445
|
});
|
|
519
|
-
const { stdout } = await testCommand(Debug, []
|
|
446
|
+
const { stdout } = await testCommand(Debug, [], {
|
|
447
|
+
mocks: defaultMocks
|
|
448
|
+
});
|
|
520
449
|
expect(stdout).toContain('User:');
|
|
521
450
|
// Should show error message in red
|
|
522
451
|
expect(stdout).toMatch(/Request failed with status code 500|Failed to fetch user info|Internal server error/);
|
|
@@ -528,17 +457,6 @@ describe('#debug', ()=>{
|
|
|
528
457
|
if (key === 'authToken') return 'mock-auth-token';
|
|
529
458
|
return undefined;
|
|
530
459
|
});
|
|
531
|
-
// Mock project configuration
|
|
532
|
-
vi.mocked(findProjectRoot).mockResolvedValue({
|
|
533
|
-
directory: '/test/project',
|
|
534
|
-
path: '/test/project/sanity.cli.ts',
|
|
535
|
-
type: 'studio'
|
|
536
|
-
});
|
|
537
|
-
vi.mocked(getCliConfig).mockResolvedValue({
|
|
538
|
-
api: {
|
|
539
|
-
projectId: 'project123'
|
|
540
|
-
}
|
|
541
|
-
});
|
|
542
460
|
vi.mocked(findSanityModulesVersions).mockResolvedValue([]);
|
|
543
461
|
// Mock the /me API endpoint to return user info
|
|
544
462
|
mockApi({
|
|
@@ -556,7 +474,9 @@ describe('#debug', ()=>{
|
|
|
556
474
|
}).reply(404, {
|
|
557
475
|
error: 'Project not found'
|
|
558
476
|
});
|
|
559
|
-
const { stdout } = await testCommand(Debug, []
|
|
477
|
+
const { stdout } = await testCommand(Debug, [], {
|
|
478
|
+
mocks: defaultMocks
|
|
479
|
+
});
|
|
560
480
|
expect(stdout).toContain('User:');
|
|
561
481
|
expect(stdout).toContain("Email: 'test@example.com'");
|
|
562
482
|
// Should not contain Project section since it failed to load
|
|
@@ -569,17 +489,6 @@ describe('#debug', ()=>{
|
|
|
569
489
|
if (key === 'authToken') return 'mock-auth-token';
|
|
570
490
|
return undefined;
|
|
571
491
|
});
|
|
572
|
-
// Mock project configuration
|
|
573
|
-
vi.mocked(findProjectRoot).mockResolvedValue({
|
|
574
|
-
directory: '/test/project',
|
|
575
|
-
path: '/test/project/sanity.cli.ts',
|
|
576
|
-
type: 'studio'
|
|
577
|
-
});
|
|
578
|
-
vi.mocked(getCliConfig).mockResolvedValue({
|
|
579
|
-
api: {
|
|
580
|
-
projectId: 'project123'
|
|
581
|
-
}
|
|
582
|
-
});
|
|
583
492
|
vi.mocked(findSanityModulesVersions).mockResolvedValue([]);
|
|
584
493
|
// Mock the /me API endpoint to return user info
|
|
585
494
|
mockApi({
|
|
@@ -597,7 +506,9 @@ describe('#debug', ()=>{
|
|
|
597
506
|
}).reply(200, ()=>{
|
|
598
507
|
return null;
|
|
599
508
|
});
|
|
600
|
-
const { stdout } = await testCommand(Debug, []
|
|
509
|
+
const { stdout } = await testCommand(Debug, [], {
|
|
510
|
+
mocks: defaultMocks
|
|
511
|
+
});
|
|
601
512
|
expect(stdout).toContain('User:');
|
|
602
513
|
expect(stdout).toContain("Email: 'test@example.com'");
|
|
603
514
|
// Project error is handled internally but not displayed to user
|
|
@@ -610,17 +521,6 @@ describe('#debug', ()=>{
|
|
|
610
521
|
if (key === 'authToken') return 'mock-auth-token';
|
|
611
522
|
return undefined;
|
|
612
523
|
});
|
|
613
|
-
// Mock project configuration
|
|
614
|
-
vi.mocked(findProjectRoot).mockResolvedValue({
|
|
615
|
-
directory: '/test/project',
|
|
616
|
-
path: '/test/project/sanity.cli.ts',
|
|
617
|
-
type: 'studio'
|
|
618
|
-
});
|
|
619
|
-
vi.mocked(getCliConfig).mockResolvedValue({
|
|
620
|
-
api: {
|
|
621
|
-
projectId: 'project123'
|
|
622
|
-
}
|
|
623
|
-
});
|
|
624
524
|
vi.mocked(findSanityModulesVersions).mockResolvedValue([]);
|
|
625
525
|
// Mock the /me API endpoint to return user info
|
|
626
526
|
mockApi({
|
|
@@ -640,7 +540,9 @@ describe('#debug', ()=>{
|
|
|
640
540
|
id: 'project123',
|
|
641
541
|
studioHost: 'test-project'
|
|
642
542
|
});
|
|
643
|
-
const { stdout } = await testCommand(Debug, []
|
|
543
|
+
const { stdout } = await testCommand(Debug, [], {
|
|
544
|
+
mocks: defaultMocks
|
|
545
|
+
});
|
|
644
546
|
expect(stdout).toContain('Project:');
|
|
645
547
|
expect(stdout).toContain("Display name: 'Test Project'");
|
|
646
548
|
expect(stdout).toContain("Roles: [ '<none>' ]");
|
|
@@ -652,17 +554,6 @@ describe('#debug', ()=>{
|
|
|
652
554
|
if (key === 'authToken') return 'mock-auth-token';
|
|
653
555
|
return undefined;
|
|
654
556
|
});
|
|
655
|
-
// Mock project configuration
|
|
656
|
-
vi.mocked(findProjectRoot).mockResolvedValue({
|
|
657
|
-
directory: '/test/project',
|
|
658
|
-
path: '/test/project/sanity.cli.ts',
|
|
659
|
-
type: 'studio'
|
|
660
|
-
});
|
|
661
|
-
vi.mocked(getCliConfig).mockResolvedValue({
|
|
662
|
-
api: {
|
|
663
|
-
projectId: 'project123'
|
|
664
|
-
}
|
|
665
|
-
});
|
|
666
557
|
vi.mocked(findSanityModulesVersions).mockResolvedValue([]);
|
|
667
558
|
// Mock the /me API endpoint to return user info
|
|
668
559
|
mockApi({
|
|
@@ -687,7 +578,9 @@ describe('#debug', ()=>{
|
|
|
687
578
|
],
|
|
688
579
|
studioHost: 'test-project'
|
|
689
580
|
});
|
|
690
|
-
const { stdout } = await testCommand(Debug, []
|
|
581
|
+
const { stdout } = await testCommand(Debug, [], {
|
|
582
|
+
mocks: defaultMocks
|
|
583
|
+
});
|
|
691
584
|
expect(stdout).toContain('Project:');
|
|
692
585
|
expect(stdout).toContain("Display name: 'Test Project'");
|
|
693
586
|
expect(stdout).toContain("Roles: [ '<none>' ]");
|