1#!/usr/bin/env node2'use strict';34// The Shopify session check. Run from rp-source-shopify:5//6// node scripts/shopify-session-check.js --project <migrations-root>/<project> [--install] [--connect]7// node scripts/shopify-session-check.js --project <dir> --confirm-staff-removal owner-removed-account8// node scripts/shopify-session-check.js --project <dir> --repair-staff-access9//10// The store is SHOPIFY_SHOP_DOMAIN in config/source.shopify.env.11//12// (no flag) Node.js >= 22.12, the adapter's CLI 4.8.3, the connection, the scope readback and13// the API-version canary; writes data/shopify-discovery/session-receipt.json.14// --install the operator consents to installing (or reinstalling) the adapter's own CLI 4.8.3
54 if (error.code === 'ENOENT') throw new session.ShopifySessionStop('shopify_shop_domain_missing', `${SHOPIFY_SOURCE_ENV} is missing; record SHOPIFY_SHOP_DOMAIN=<shop>.myshopify.com there.`);
55 throw error;
56 }
57 if (!values.SHOPIFY_SHOP_DOMAIN) throw new session.ShopifySessionStop('shopify_shop_domain_missing', `SHOPIFY_SHOP_DOMAIN is missing from ${SHOPIFY_SOURCE_ENV}.`);
96 ...(confirmed ? {} : { requestId: result.firstConnection.requestId, message: 'Discovery does not start until the first-connection question is answered dedicated-account.' }),
97 });
98 return confirmed ? 0 : 3;
99 } catch (error) {
100 if (error instanceof session.ShopifySessionStop || error instanceof ShopifyCliError) {