diff --git a/packages/hydrogen-react/docs/build-docs.sh b/packages/hydrogen-react/docs/build-docs.sh index 8eadafda0e..d063036f7d 100644 --- a/packages/hydrogen-react/docs/build-docs.sh +++ b/packages/hydrogen-react/docs/build-docs.sh @@ -1,11 +1,27 @@ -COMPILE_DOCS="pnpm exec tsc --project docs/tsconfig.docs.json --types react --moduleResolution node --target esNext --module CommonJS && generate-docs --overridePath ./docs/typeOverride.json --input ./src --output ./docs/generated && rm -rf src/**/*.doc.js src/*.doc.js" -COMPILE_STATIC_PAGES="pnpm exec tsc docs/staticPages/*.doc.ts --types react --moduleResolution node --target esNext --module CommonJS && generate-docs --isLandingPage --input ./docs/staticPages --output ./docs/generated && rm -rf docs/staticPages/*.doc.js" +OUTPUT_DIR="./docs/generated" +V2_TEMP_DIR="./docs/generated_v2_temp" + +COMPILE_DOCS_V2="generate-docs --overridePath ./docs/typeOverride.json --input ./src --output $V2_TEMP_DIR" +COMPILE_DOCS="pnpm exec tsc --project docs/tsconfig.docs.json --types react --moduleResolution node --target esNext --module CommonJS && generate-docs --overridePath ./docs/typeOverride.json --input ./src --output $OUTPUT_DIR && rm -rf src/**/*.doc.js src/*.doc.js" +COMPILE_STATIC_PAGES="pnpm exec tsc docs/staticPages/*.doc.ts --types react --moduleResolution node --target esNext --module CommonJS && generate-docs --isLandingPage --input ./docs/staticPages --output $OUTPUT_DIR && rm -rf docs/staticPages/*.doc.js" if [ "$1" = "isTest" ]; then -COMPILE_DOCS="pnpm exec tsc --project docs/tsconfig.docs.json --types react --moduleResolution node --target esNext --module CommonJS && generate-docs --overridePath ./docs/typeOverride.json --input ./src --output ./docs/temp && rm -rf src/**/*.doc.js src/*.doc.js" -COMPILE_STATIC_PAGES="pnpm exec tsc docs/staticPages/*.doc.ts --types react --moduleResolution node --target esNext --module CommonJS && generate-docs --isLandingPage --input ./docs/staticPages --output ./docs/temp && rm -rf docs/staticPages/*.doc.js" +OUTPUT_DIR="./docs/temp" +V2_TEMP_DIR="./docs/temp_v2" +COMPILE_DOCS_V2="generate-docs --overridePath ./docs/typeOverride.json --input ./src --output $V2_TEMP_DIR" +COMPILE_DOCS="pnpm exec tsc --project docs/tsconfig.docs.json --types react --moduleResolution node --target esNext --module CommonJS && generate-docs --overridePath ./docs/typeOverride.json --input ./src --output $OUTPUT_DIR && rm -rf src/**/*.doc.js src/*.doc.js" +COMPILE_STATIC_PAGES="pnpm exec tsc docs/staticPages/*.doc.ts --types react --moduleResolution node --target esNext --module CommonJS && generate-docs --isLandingPage --input ./docs/staticPages --output $OUTPUT_DIR && rm -rf docs/staticPages/*.doc.js" fi -eval $COMPILE_DOCS +eval $COMPILE_DOCS_V2 +eval $COMPILE_DOCS eval $COMPILE_STATIC_PAGES + +cp "$V2_TEMP_DIR/generated_docs_data_v2.json" "$OUTPUT_DIR/generated_docs_data_v2.json" +rm -rf "$V2_TEMP_DIR" + +if [ "$1" != "isTest" ]; +then +node ./docs/copy-docs-to-shopify-dev.mjs +fi diff --git a/packages/hydrogen-react/docs/copy-docs-to-shopify-dev.mjs b/packages/hydrogen-react/docs/copy-docs-to-shopify-dev.mjs new file mode 100644 index 0000000000..031807da8b --- /dev/null +++ b/packages/hydrogen-react/docs/copy-docs-to-shopify-dev.mjs @@ -0,0 +1,59 @@ +import {promises as fs} from 'fs'; +import path from 'path'; +import {fileURLToPath} from 'url'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + +const SHOPIFY_DEV_DB_SUBPATH = + 'areas/platforms/shopify-dev/db/data/docs/templated_apis'; + +const HYDROGEN_REACT_VERSION = '2026-01'; + +async function copyGeneratedToShopifyDev() { + const generatedDocsPath = path.resolve( + __dirname, + './generated/generated_docs_data_v2.json', + ); + + // Find the shopify-dev repo: try world first, then relative fallback + const rootPath = path.resolve(__dirname, '../../..'); + const worldPath = path.join(process.env.HOME, 'world/trees/root/src'); + + let shopifyDevPath; + try { + await fs.access(worldPath); + shopifyDevPath = worldPath; + } catch { + shopifyDevPath = path.join(rootPath, '../../../shopify-dev'); + } + + const shopifyDevDBPath = path.join(shopifyDevPath, SHOPIFY_DEV_DB_SUBPATH); + + try { + await fs.access(shopifyDevDBPath); + } catch { + console.warn( + `[h2-react:docs] shopify-dev not found at ${shopifyDevDBPath}. Skipping copy.`, + ); + return; + } + + const destDir = path.join( + shopifyDevDBPath, + 'hydrogen_react', + HYDROGEN_REACT_VERSION, + ); + const destFile = path.join(destDir, 'generated_docs_data_v2.json'); + + await fs.mkdir(destDir, {recursive: true}); + await fs.copyFile(generatedDocsPath, destFile); + + console.log( + `[h2-react:docs] Copied generated_docs_data_v2.json → ${destFile}`, + ); +} + +copyGeneratedToShopifyDev().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/packages/hydrogen-react/docs/generated/generated_docs_data.json b/packages/hydrogen-react/docs/generated/generated_docs_data.json index edbf033d29..bb656bf39c 100644 --- a/packages/hydrogen-react/docs/generated/generated_docs_data.json +++ b/packages/hydrogen-react/docs/generated/generated_docs_data.json @@ -35,6 +35,7 @@ "filePath": "src/AddToCartButton.tsx", "name": "AddToCartButtonPropsForDocs", "description": "", + "isPublicDocs": true, "members": [ { "filePath": "src/AddToCartButton.tsx", @@ -165,6 +166,7 @@ "filePath": "src/BuyNowButton.tsx", "name": "BuyNowButtonPropsForDocs", "description": "", + "isPublicDocs": true, "members": [ { "filePath": "src/BuyNowButton.tsx", @@ -279,6 +281,7 @@ "filePath": "src/CartCheckoutButton.tsx", "name": "CartCheckoutButtonPropsForDocs", "description": "", + "isPublicDocs": true, "members": [ { "filePath": "src/CartCheckoutButton.tsx", @@ -354,6 +357,7 @@ "filePath": "src/CartCost.tsx", "name": "CartCostPropsForDocs", "description": "", + "isPublicDocs": true, "members": [ { "filePath": "src/CartCost.tsx", @@ -384,7 +388,7 @@ "syntaxKind": "PropertySignature", "name": "measurement", "value": "PartialDeep", - "description": "A [UnitPriceMeasurement object](https://shopify.dev/api/storefront/2026-01/objects/unitpricemeasurement).", + "description": "A [UnitPriceMeasurement object](https://shopify.dev/api/storefront/2026-04/objects/unitpricemeasurement).", "isOptional": true }, { @@ -462,6 +466,7 @@ "name": "CartLineProviderProps", "value": "{\n /** Any `ReactNode` elements. */\n children: ReactNode;\n /** A cart line object. */\n line: CartLinePartialDeep;\n}", "description": "", + "isPublicDocs": true, "members": [ { "filePath": "src/CartLineProvider.tsx", @@ -483,7 +488,7 @@ "filePath": "src/CartLineProvider.tsx", "syntaxKind": "TypeAliasDeclaration", "name": "CartLinePartialDeep", - "value": "any", + "value": "PartialDeep<\n CartLine | ComponentizableCartLine,\n {recurseIntoArrays: true}\n>", "description": "" } } @@ -537,6 +542,7 @@ "filePath": "src/CartLineQuantity.tsx", "name": "CartLineQuantityBaseProps", "description": "", + "isPublicDocs": true, "members": [ { "filePath": "src/CartLineQuantity.tsx", @@ -600,6 +606,7 @@ "filePath": "src/CartLineQuantityAdjustButton.tsx", "name": "CartLineQuantityAdjustButtonBaseProps", "description": "", + "isPublicDocs": true, "members": [ { "filePath": "src/CartLineQuantityAdjustButton.tsx", @@ -663,15 +670,16 @@ "filePath": "src/CartProvider.tsx", "syntaxKind": "TypeAliasDeclaration", "name": "CartProviderProps", - "value": "{\n /** Any `ReactNode` elements. */\n children: React.ReactNode;\n /** Maximum number of cart lines to fetch. Defaults to 250 cart lines. */\n numCartLines?: number;\n /** A callback that is invoked when the process to create a cart begins, but before the cart is created in the Storefront API. */\n onCreate?: () => void;\n /** A callback that is invoked when the process to add a line item to the cart begins, but before the line item is added to the Storefront API. */\n onLineAdd?: () => void;\n /** A callback that is invoked when the process to remove a line item to the cart begins, but before the line item is removed from the Storefront API. */\n onLineRemove?: () => void;\n /** A callback that is invoked when the process to update a line item in the cart begins, but before the line item is updated in the Storefront API. */\n onLineUpdate?: () => void;\n /** A callback that is invoked when the process to add or update a note in the cart begins, but before the note is added or updated in the Storefront API. */\n onNoteUpdate?: () => void;\n /** A callback that is invoked when the process to update the buyer identity begins, but before the buyer identity is updated in the Storefront API. */\n onBuyerIdentityUpdate?: () => void;\n /** A callback that is invoked when the process to update the cart attributes begins, but before the attributes are updated in the Storefront API. */\n onAttributesUpdate?: () => void;\n /** A callback that is invoked when the process to update the cart discount codes begins, but before the discount codes are updated in the Storefront API. */\n onDiscountCodesUpdate?: () => void;\n /** A callback that is invoked when the process to create a cart completes */\n onCreateComplete?: () => void;\n /** A callback that is invoked when the process to add a line item to the cart completes */\n onLineAddComplete?: () => void;\n /** A callback that is invoked when the process to remove a line item to the cart completes */\n onLineRemoveComplete?: () => void;\n /** A callback that is invoked when the process to update a line item in the cart completes */\n onLineUpdateComplete?: () => void;\n /** A callback that is invoked when the process to add or update a note in the cart completes */\n onNoteUpdateComplete?: () => void;\n /** A callback that is invoked when the process to update the buyer identity completes */\n onBuyerIdentityUpdateComplete?: () => void;\n /** A callback that is invoked when the process to update the cart attributes completes */\n onAttributesUpdateComplete?: () => void;\n /** A callback that is invoked when the process to update the cart discount codes completes */\n onDiscountCodesUpdateComplete?: () => void;\n /** An object with fields that correspond to the Storefront API's [Cart object](https://shopify.dev/api/storefront/2026-01/objects/cart). */\n data?: PartialDeep;\n /** A fragment used to query the Storefront API's [Cart object](https://shopify.dev/api/storefront/2026-01/objects/cart) for all queries and mutations. A default value is used if no argument is provided. */\n cartFragment?: string;\n /** A customer access token that's accessible on the server if there's a customer login. */\n customerAccessToken?: CartBuyerIdentityInput['customerAccessToken'];\n /** The ISO country code for i18n. */\n countryCode?: CountryCode;\n /** The ISO language code for i18n. */\n languageCode?: LanguageCode;\n}", + "value": "{\n /** Any `ReactNode` elements. */\n children: React.ReactNode;\n /** Maximum number of cart lines to fetch. Defaults to 250 cart lines. */\n numCartLines?: number;\n /** A callback that is invoked when the process to create a cart begins, but before the cart is created in the Storefront API. */\n onCreate?: () => void;\n /** A callback that is invoked when the process to add a line item to the cart begins, but before the line item is added to the Storefront API. */\n onLineAdd?: () => void;\n /** A callback that is invoked when the process to remove a line item to the cart begins, but before the line item is removed from the Storefront API. */\n onLineRemove?: () => void;\n /** A callback that is invoked when the process to update a line item in the cart begins, but before the line item is updated in the Storefront API. */\n onLineUpdate?: () => void;\n /** A callback that is invoked when the process to add or update a note in the cart begins, but before the note is added or updated in the Storefront API. */\n onNoteUpdate?: () => void;\n /** A callback that is invoked when the process to update the buyer identity begins, but before the buyer identity is updated in the Storefront API. */\n onBuyerIdentityUpdate?: () => void;\n /** A callback that is invoked when the process to update the cart attributes begins, but before the attributes are updated in the Storefront API. */\n onAttributesUpdate?: () => void;\n /** A callback that is invoked when the process to update the cart discount codes begins, but before the discount codes are updated in the Storefront API. */\n onDiscountCodesUpdate?: () => void;\n /** A callback that is invoked when the process to create a cart completes */\n onCreateComplete?: () => void;\n /** A callback that is invoked when the process to add a line item to the cart completes */\n onLineAddComplete?: () => void;\n /** A callback that is invoked when the process to remove a line item to the cart completes */\n onLineRemoveComplete?: () => void;\n /** A callback that is invoked when the process to update a line item in the cart completes */\n onLineUpdateComplete?: () => void;\n /** A callback that is invoked when the process to add or update a note in the cart completes */\n onNoteUpdateComplete?: () => void;\n /** A callback that is invoked when the process to update the buyer identity completes */\n onBuyerIdentityUpdateComplete?: () => void;\n /** A callback that is invoked when the process to update the cart attributes completes */\n onAttributesUpdateComplete?: () => void;\n /** A callback that is invoked when the process to update the cart discount codes completes */\n onDiscountCodesUpdateComplete?: () => void;\n /** An object with fields that correspond to the Storefront API's [Cart object](https://shopify.dev/api/storefront/2026-04/objects/cart). */\n data?: PartialDeep;\n /** A fragment used to query the Storefront API's [Cart object](https://shopify.dev/api/storefront/2026-04/objects/cart) for all queries and mutations. A default value is used if no argument is provided. */\n cartFragment?: string;\n /** A customer access token that's accessible on the server if there's a customer login. */\n customerAccessToken?: CartBuyerIdentityInput['customerAccessToken'];\n /** The ISO country code for i18n. */\n countryCode?: CountryCode;\n /** The ISO language code for i18n. */\n languageCode?: LanguageCode;\n}", "description": "", + "isPublicDocs": true, "members": [ { "filePath": "src/CartProvider.tsx", "syntaxKind": "PropertySignature", "name": "cartFragment", "value": "string", - "description": "A fragment used to query the Storefront API's [Cart object](https://shopify.dev/api/storefront/2026-01/objects/cart) for all queries and mutations. A default value is used if no argument is provided.", + "description": "A fragment used to query the Storefront API's [Cart object](https://shopify.dev/api/storefront/2026-04/objects/cart) for all queries and mutations. A default value is used if no argument is provided.", "isOptional": true }, { @@ -702,7 +710,7 @@ "syntaxKind": "PropertySignature", "name": "data", "value": "PartialDeep", - "description": "An object with fields that correspond to the Storefront API's [Cart object](https://shopify.dev/api/storefront/2026-01/objects/cart).", + "description": "An object with fields that correspond to the Storefront API's [Cart object](https://shopify.dev/api/storefront/2026-04/objects/cart).", "isOptional": true }, { @@ -896,7 +904,8 @@ "ExternalVideoBaseProps": { "filePath": "src/ExternalVideo.tsx", "name": "ExternalVideoBaseProps", - "description": "", + "description": "Takes in the same props as a native `