diff --git a/packages/sanity/src/_internal/cli/actions/manifest/extractManifestAction.ts b/packages/sanity/src/_internal/cli/actions/manifest/extractManifestAction.ts index fd3b65ae934..caaa00f8196 100644 --- a/packages/sanity/src/_internal/cli/actions/manifest/extractManifestAction.ts +++ b/packages/sanity/src/_internal/cli/actions/manifest/extractManifestAction.ts @@ -27,32 +27,35 @@ const CREATE_TIMER = 'create-manifest' const EXTRACT_TASK_TIMEOUT_MS = minutesToMilliseconds(2) +const EXTRACT_FAILURE_MESSAGE = + 'Unable to extract manifest. Certain features like Sanity Create will not work with this studio.\n' + + //TODO: replace this link + 'For more information, see: https://www.sanity.io/docs/cli' + interface ExtractFlags { path?: string } /** - * This method will never throw + * This function will never throw. + * @returns `undefined` if extract succeeded - caught error if it failed */ export async function extractManifestSafe( args: CliCommandArguments, context: CliCommandContext, -): Promise { +): Promise { if (EXTRACT_MANIFEST_DISABLED) { - return + return undefined } try { await extractManifest(args, context) + return undefined } catch (err) { - // best-effort extraction - context.output.print( - 'Unable to extract manifest. Certain features like Sanity Create will not work with this studio.\n' + - `To disable manifest extraction set ${FEATURE_ENABLED_ENV_NAME}=false`, - ) if (EXTRACT_MANIFEST_LOG_ERRORS) { context.output.error(err) } + return err } } @@ -98,7 +101,7 @@ async function extractManifest( spinner.succeed(`Extracted manifest (${manifestDuration.toFixed()}ms)`) } catch (err) { - spinner.fail() + spinner.info(EXTRACT_FAILURE_MESSAGE) throw err } } diff --git a/packages/sanity/src/_internal/cli/commands/manifest/extractManifestCommand.ts b/packages/sanity/src/_internal/cli/commands/manifest/extractManifestCommand.ts index e3d3922622f..7422524e2a4 100644 --- a/packages/sanity/src/_internal/cli/commands/manifest/extractManifestCommand.ts +++ b/packages/sanity/src/_internal/cli/commands/manifest/extractManifestCommand.ts @@ -24,7 +24,11 @@ const extractManifestCommand: CliCommandDefinition = { helpText, action: async (args, context) => { const {extractManifestSafe} = await import('../../actions/manifest/extractManifestAction') - return extractManifestSafe(args, context) + const extractError = await extractManifestSafe(args, context) + if (extractError) { + throw extractError + } + return extractError }, }