diff --git a/.changeset/strange-drinks-move.md b/.changeset/strange-drinks-move.md new file mode 100644 index 0000000000..6d3e40559f --- /dev/null +++ b/.changeset/strange-drinks-move.md @@ -0,0 +1,5 @@ +--- +'@shopify/app': minor +--- + +Remove zod schemas from app info (JSON format) diff --git a/packages/app/src/cli/services/info.ts b/packages/app/src/cli/services/info.ts index e9b912350b..69dc511613 100644 --- a/packages/app/src/cli/services/info.ts +++ b/packages/app/src/cli/services/info.ts @@ -45,17 +45,56 @@ export async function infoWeb(app: AppInterface, {format}: InfoOptions): Promise export async function infoApp(app: AppInterface, options: InfoOptions): Promise { if (options.format === 'json') { - const appWithSupportedExtensions = { + const extensionsInfo = withPurgedSchemas(app.allExtensions.filter((ext) => ext.isReturnedAsInfo())) + let appWithSupportedExtensions = { ...app, - allExtensions: app.allExtensions.filter((ext) => ext.isReturnedAsInfo()), + allExtensions: extensionsInfo, } - return outputContent`${JSON.stringify(appWithSupportedExtensions, null, 2)}` + if ('realExtensions' in appWithSupportedExtensions) { + appWithSupportedExtensions.realExtensions = withPurgedSchemas( + appWithSupportedExtensions.realExtensions as ExtensionInstance[], + ) + } + if ('specifications' in appWithSupportedExtensions) { + appWithSupportedExtensions = { + ...appWithSupportedExtensions, + specifications: appWithSupportedExtensions.specifications?.map((spec) => { + // We are choosing to leave appWithSupportedExtensions as close to the original as possible, + // instead allowing this one change in the type specifically. + // + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return objectWithoutSchema(spec) as any + }), + } + } + return outputContent`${JSON.stringify( + Object.fromEntries(Object.entries(appWithSupportedExtensions).filter(([key]) => key !== 'configSchema')), + null, + 2, + )}` } else { const appInfo = new AppInfo(app, options) return appInfo.output() } } +function objectWithoutSchema(obj: T): Omit { + const {schema, ...rest} = obj + return rest +} + +function withPurgedSchemas(extensions: T[]): T[] { + return extensions.map((ext) => { + if ('specification' in ext) { + const specification = ext.specification! + const specificationWithoutSchema = objectWithoutSchema(specification) + return {...ext, specification: specificationWithoutSchema} + } else { + return ext + } + }) +} + const UNKNOWN_TEXT = outputContent`${outputToken.italic('unknown')}`.value const NOT_CONFIGURED_TEXT = outputContent`${outputToken.italic('Not yet configured')}`.value