From fd0ab7398adc73967c86a7d4505ac9c6f9daafcf Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Fri, 4 Oct 2024 14:30:03 -0600 Subject: [PATCH 1/2] Do not throw an error during migrate if the project ID is passed via the --project option instead of the cli config --- .../cli/commands/migration/runMigrationCommand.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/sanity/src/_internal/cli/commands/migration/runMigrationCommand.ts b/packages/sanity/src/_internal/cli/commands/migration/runMigrationCommand.ts index ab0a33ca8c3..df2aae01c21 100644 --- a/packages/sanity/src/_internal/cli/commands/migration/runMigrationCommand.ts +++ b/packages/sanity/src/_internal/cli/commands/migration/runMigrationCommand.ts @@ -164,9 +164,15 @@ const runMigrationCommand: CliCommandDefinition = { const projectConfig = apiClient({ requireUser: true, - requireProject: true, + requireProject: false, }).config() + if (!project && projectConfig.projectId) { + throw new Error( + 'sanity.cli.js does not contain a project identifier ("api.projectId") and no --project option was provided.', + ) + } + const apiConfig = { dataset: dataset ?? projectConfig.dataset!, projectId: project ?? projectConfig.projectId!, From dd54d6151b89ff6f1307c485472dc7e82087f7ca Mon Sep 17 00:00:00 2001 From: Ryan Bonial <4294665+ryanbonial@users.noreply.github.com> Date: Sat, 5 Oct 2024 08:16:21 -0600 Subject: [PATCH 2/2] Fix missing ! typo Co-authored-by: Espen Hovlandsdal --- .../src/_internal/cli/commands/migration/runMigrationCommand.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sanity/src/_internal/cli/commands/migration/runMigrationCommand.ts b/packages/sanity/src/_internal/cli/commands/migration/runMigrationCommand.ts index df2aae01c21..196087823dd 100644 --- a/packages/sanity/src/_internal/cli/commands/migration/runMigrationCommand.ts +++ b/packages/sanity/src/_internal/cli/commands/migration/runMigrationCommand.ts @@ -167,7 +167,7 @@ const runMigrationCommand: CliCommandDefinition = { requireProject: false, }).config() - if (!project && projectConfig.projectId) { + if (!project && !projectConfig.projectId) { throw new Error( 'sanity.cli.js does not contain a project identifier ("api.projectId") and no --project option was provided.', )