UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

1 lines • 1.86 kB
import{defineSetupIntegration}from"../types.js";import{SHOPIFY_UCP_CHANNEL_TEMPLATE}from"./templates.js";import{join}from"node:path";import{writeTextFile}from"#setup/scaffold/files.js";import{text}from"#setup/ask.js";import{appendEnv}from"#setup/append-env.js";const defaultDeps={appendEnv,writeTextFile};function normalizeStoreDomain(e){return e.trim().replace(/^https?:\/\//i,``).replace(/[/?#].*$/,``)}function validateStoreDomain(e){let t=normalizeStoreDomain(e);try{let e=new URL(`https://${t}`);return t.length>0&&e.hostname.includes(`.`)&&!e.username&&!e.password&&!e.port?null:`Enter a valid Shopify storefront domain.`}catch{return`Enter a valid Shopify storefront domain.`}}async function prepareShopifySetup(e){return{storeDomain:normalizeStoreDomain(await e.asker.ask(text({key:`shopify.store-domain`,message:`Shopify storefront domain`,placeholder:`your-store.myshopify.com`,required:!0,validate:validateStoreDomain})))}}async function applyShopifySetup(e,t,n=defaultDeps){return t.presenter.log.message(`Scaffolding Shopify UCP channel and storefront environment...`),await n.appendEnv(join(t.projectRoot,`.env.local`),{SHOPIFY_STORE_DOMAIN:e.storeDomain}),await n.writeTextFile(join(t.appRoot,`agent/channels/ucp.ts`),SHOPIFY_UCP_CHANNEL_TEMPLATE,{force:t.force}),t.presenter.log.success(`Scaffolded channel: ucp`),t.presenter.nextSteps([`Set SHOPIFY_STORE_DOMAIN in .env.local.`,"Shopify cannot reach localhost, so `eve dev` uses Shopify's example agent profile automatically. To test your own profile locally, expose the /.well-known/ucp route with a tool like ngrok."]),{deploymentRequired:!0,facts:[{label:`Store domain`,value:e.storeDomain,kind:`text`}]}}const SHOPIFY_SETUP=defineSetupIntegration({kind:`shopify`,label:`Shopify`,prepare:prepareShopifySetup,apply:applyShopifySetup});export{SHOPIFY_SETUP,applyShopifySetup,prepareShopifySetup};