diff --git a/packages/@sanity/cli/src/actions/init-project/initProject.ts b/packages/@sanity/cli/src/actions/init-project/initProject.ts index fe87d5eb5dd..dac97466649 100644 --- a/packages/@sanity/cli/src/actions/init-project/initProject.ts +++ b/packages/@sanity/cli/src/actions/init-project/initProject.ts @@ -594,26 +594,31 @@ export default async function initSanity( trace.log({step: 'importTemplateDataset', selectedOption: shouldImport ? 'yes' : 'no'}) - // Bootstrap Sanity, creating required project files, manifests etc - await bootstrapTemplate(templateOptions, context) - - // update that files were initialized locally; do not halt flow for request - apiClient({api: {projectId: projectId}}) - .request({uri: `/projects/${projectId}`}) - .then((project: SanityProject) => { - if (!project?.metadata?.cliInitializedAt) { - return apiClient({api: {projectId}}).request({ - method: 'PATCH', - uri: `/projects/${projectId}`, - body: {metadata: {cliInitializedAt: new Date().toISOString()}}, - }) - } - return Promise.resolve() - }) - .catch(() => { - // Non-critical update - debug('Failed to update cliInitializedAt metadata') - }) + const [_, bootstrapPromise] = await Promise.allSettled([ + // record template files attempted to be created locally + apiClient({api: {projectId: projectId}}) + .request({uri: `/projects/${projectId}`}) + .then((project: SanityProject) => { + if (!project?.metadata?.cliInitializedAt) { + return apiClient({api: {projectId}}).request({ + method: 'PATCH', + uri: `/projects/${projectId}`, + body: {metadata: {cliInitializedAt: new Date().toISOString()}}, + }) + } + return Promise.resolve() + }) + .catch(() => { + // Non-critical update + debug('Failed to update cliInitializedAt metadata') + }), + // Bootstrap Sanity, creating required project files, manifests etc + bootstrapTemplate(templateOptions, context), + ]) + + if (bootstrapPromise.status === 'rejected' && bootstrapPromise.reason instanceof Error) { + throw bootstrapPromise.reason + } let pkgManager: PackageManager