@shopify/cli
Version:
A CLI tool to build for the Shopify platform
9 lines (5 loc) • 5.16 kB
JavaScript
import{k as L,q as P}from"../../../chunk-XITQULK4.js";import"../../../chunk-UJVH7FZS.js";import{c as g,l as v}from"../../../chunk-TYZXGSHO.js";import"../../../chunk-VBUZWRUL.js";import"../../../chunk-4DCQNGUV.js";import"../../../chunk-XONFGLJQ.js";import"../../../chunk-4LNCYIS3.js";import"../../../chunk-L2MGAEV3.js";import"../../../chunk-PRKBO42R.js";import"../../../chunk-ZSBA6VIC.js";import"../../../chunk-F2QU6WWX.js";import"../../../chunk-XULPJ6UG.js";import{b as _}from"../../../chunk-XR6GMMEU.js";import"../../../chunk-3TNEIDOD.js";import"../../../chunk-MHWV5RQV.js";import"../../../chunk-XOTA6JTZ.js";import"../../../chunk-MOA33ZFO.js";import"../../../chunk-JUVAGMIH.js";import{D as y,F as C,R,w as T,z as k}from"../../../chunk-6G6TMKXF.js";import"../../../chunk-P6XE4MH5.js";import"../../../chunk-KLMDWDT2.js";import"../../../chunk-5CH3B62S.js";import"../../../chunk-QUTQDXSL.js";import"../../../chunk-WSDN25F5.js";import{d as N}from"../../../chunk-M56NDIMD.js";import"../../../chunk-PD5ZHJWI.js";import{r as j}from"../../../chunk-LDGAHMS7.js";import"../../../chunk-ZR76GGZ6.js";import"../../../chunk-EENHXSWU.js";import"../../../chunk-FUOIGXI4.js";import"../../../chunk-6M3ZYNGO.js";import"../../../chunk-QYR5VPQA.js";import"../../../chunk-OBEWZXOQ.js";import{Aa as S,Ca as b,Ta as E,Va as F,ka as A,ma as f,ua as h}from"../../../chunk-N5PQPIBF.js";import"../../../chunk-CERXUPGC.js";import"../../../chunk-T4M5CWAO.js";import"../../../chunk-PRVQAHWI.js";import"../../../chunk-YTNDFQJT.js";import"../../../chunk-ULQG3XQS.js";import{d as r}from"../../../chunk-IU2ZQ6TE.js";import"../../../chunk-PIBY5DDZ.js";import{e as $,g as p}from"../../../chunk-VPRTJUIN.js";p();p();var d="https://github.com/Shopify/skeleton-theme.git",q="https://github.com/Shopify/theme-liquid-docs.git",I={all:"All",github:"VS Code (GitHub Copilot)",cursor:"Cursor",claude:"Claude"};async function O(e,t){await U(e,t)}async function G(e,t){await U(e,t,!0)}async function U(e,t,i){await y([{title:`Cloning ${e} into ${t}`,task:async()=>{await g({repoUrl:e,destination:t,latestTag:i,shallow:!0}),await v(t),e===d&&(await Promise.all(Object.keys(I).map(async s=>x(r(t,`.${s}`)))),await x(r(t,".git")))}}])}async function x(e){await E(e)&&await b(e)}async function M(){return await k({message:"Which LLM instruction file would you like to include in your theme?",choices:[...Object.entries(I).map(([t,i])=>({label:i,value:t})),{label:"Skip",value:null}]})}async function D(e,t){let i=[];await y([{title:`Adding AI instructions into ${e}`,task:async()=>{await A(async s=>{await g({repoUrl:q,destination:s,shallow:!0});let l=t==="all"?Object.keys(I).filter(o=>o!=="all"):[t];try{let o=r(s,"ai","github","copilot-instructions.md"),a=await f(o),n=r(e,"AGENTS.md"),m=`# AGENTS.md
${a}`;await h(n,m),(await Promise.all(l.map(u=>H(e,n,u)))).forEach(u=>{u.copiedFile&&i.push(u.copiedFile)})}catch{throw new N("Failed to create AI instructions")}})}}]),i.length>0&&T({headline:"Files created instead of symlinks.",body:`Shopify CLI attempted to create symbolic links between AGENTS.md and ${i.join(", ")}, but your system doesn't have Developer Mode enabled or symlinks are disabled. Separate files were created instead.`})}async function H(e,t,i){if(i==="cursor")return{};let l={github:"copilot-instructions.md",claude:"CLAUDE.md"}[i],o=r(e,l);try{return await S(t,o),{}}catch(a){if(a instanceof Error){let n=await f(t);return await h(o,n),{copiedFile:l}}else throw a}}var c=$(j(),1);var w=class extends P{static{this.summary="Clones a Git repository to use as a starting point for building a new theme."}static{this.descriptionWithMarkdown=`Clones a Git repository to your local machine to use as the starting point for building a theme.
If no Git repository is specified, then this command creates a copy of Shopify's [Skeleton theme](${d}), with the specified name in the current folder. If no name is provided, then you're prompted to enter one.
> Caution: If you're building a theme for the Shopify Theme Store, then you can use our example theme as a starting point. However, the theme that you submit needs to be [substantively different from existing themes](https://shopify.dev/docs/themes/store/requirements#uniqueness) so that it provides added value for users.
`}static{this.description=this.descriptionWithoutMarkdown()}static{this.usage="theme init [name] [flags]"}static{this.args={name:c.Args.string({name:"name",description:"Name of the new theme",required:!1})}}static{this.flags={..._,path:L.path,"clone-url":c.Flags.string({char:"u",default:d,description:"The Git URL to clone from. Defaults to Shopify's Skeleton theme.",env:"SHOPIFY_FLAG_CLONE_URL"}),latest:c.Flags.boolean({char:"l",description:"Downloads the latest release of the `clone-url`",env:"SHOPIFY_FLAG_LATEST"})}}static{this.multiEnvironmentsFlags=null}async command(t,i,s,l){let o=l.name??await this.promptName(t.path),a=t["clone-url"],n=r(t.path,o);if(t.latest?await G(a,n):await O(a,n),!R())return;let m=await M();m&&await D(n,m)}async promptName(t){let i=await F({suffix:"theme",directory:t,family:"creative"});return C({message:"Name of the new theme",defaultValue:i})}};export{w as default};