@tiptap/cli 3.3.5 → 3.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ Or add to your project's .npmrc file:`),o.log(" @tiptap-pro:registry=https://re
|
|
|
26
26
|
npmAuthToken: "${t}"`)):(e==="pnpm"||e==="bun")&&(o.log("Add to your project's .npmrc file:"),o.log(a.cyan(`@tiptap-pro:registry=https://registry.tiptap.dev/
|
|
27
27
|
//registry.tiptap.dev/:_authToken=${t}`)))}async function lo(e){try{return(await to("yarn",["--version"],{cwd:e})).stdout.startsWith("1.")}catch{return!1}}async function gt(e){let{email:t,password:n,writeConfig:r,showMessage:s}=e,{cwd:i}=e;t||(t=await so("Email:",{validate:p=>p?!0:"Please enter your email"})),n||(n=await io("Password:",{validate:p=>p?!0:"Please enter your password"})),(!t||!n)&&(o.error("Authentication cancelled"),process.exit(0));let c=await W(i);if(r===void 0){let p=ao(c);r=await Pe(`Would you like to save the auth token to your ${p}?`),r===void 0&&(o.error("Authentication cancelled"),process.exit(0))}let l=await rn({email:t,password:n,packageManager:c,writeConfig:r??!1,cwd:i});return l.success&&l.tokens?(r&&s?(o.log(`
|
|
28
28
|
Registry auth token saved to project directory for ${a.cyan(c)}`),o.log(`.npmrc file saved at: ${a.cyan(i)}`),o.log(`Project path: ${a.cyan(i)}`)):l.tokens.authToken&&s&&(o.log(`
|
|
29
|
-
Registry Auth Token: ${a.cyan(l.tokens.authToken)}`),o.log("This token should be added to your project's configuration:"),await co(c,l.tokens.authToken,i)),s&&o.log("Bearer token saved globally for CLI authentication"),!0):(o.error("Authentication failed: "+l.error),!1)}async function po(e){let t=await W(e),n=await xe();if(n.authenticated){if(o.success(`Authenticated as ${a.cyan(n.user??"unknown user")}`),n.plans&&n.plans.length>0?n.plans.length===1?o.log(`Plan: ${a.cyan(n.plans[0])}`):o.log(`Plans: ${a.cyan(n.plans.join(", "))}`):o.log(`Plans: ${a.cyan("No active plans")}`),n.expires){let s=new Date(n.expires),i=new Date,c=Math.ceil((s.getTime()-i.getTime())/(1e3*60*60*24));c>30?o.log(`Token expires: ${a.cyan(s.toDateString())} (${c} days)`):c>0?o.log(`Token expires: ${a.yellow(s.toDateString())} (${c} days)`):o.log(`Token expires: ${a.red("Expired")}`)}if(n.token){let s=n.token.substring(0,10)+"...";o.log(`Bearer token: ${a.cyan(s)}`)}let r=await Ue(t,e);if(r){let s=r.substring(0,10)+"...";o.log(`Registry token: ${a.cyan(s)}`)}else o.log(`Registry token: ${a.yellow("Not configured for this project")}`),o.log(`Run ${a.cyan("@tiptap/cli login --write-config")} to configure for this project`)}else o.log("Not authenticated with Tiptap registry"),o.log(`Run ${a.cyan("@tiptap/cli login")} to authenticate`)}var an=new ke().command("login").description("log in to your Tiptap Cloud account").option("-e, --email <email>","your account email").option("-p, --password <password>","your account password").option("--write-config","write the auth token to your package manager config",void 0).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async e=>{try{let t=sn.parse(e);await gt(t)}catch(t){_(t)}}),cn=new ke().command("status").description("review your Tiptap Cloud authentication status").description("log out from your Tiptap registry account").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async e=>{let t=sn.parse(e),{cwd:n}=t;try{await po(n)}catch(r){_(r)}}),ln=new ke().command("logout").description("log out from your Tiptap registry account").action(async()=>{try{let e=S("Logging out...")?.start(),t=await on();t.success?e?.stopAndPersist({symbol:a.cyan("\u2714"),text:"Successfully logged out"}):(e?.fail("Logout failed"),o.error("Logout failed: "+t.error))}catch(e){_(e)}});async function mo(){o.log(""),o.log(a.yellow("\u{1F4CB} Tiptap Pro License Information")),o.log("");let e=R.hasAcceptedLicense(),t=R.getUserInfo();e?(o.log(`${a.cyan("\u2714")} Pro License and Terms of Service accepted`),t.email&&o.log(` Accepted by: ${a.cyan(t.email)}`),o.log("")):(o.log(a.yellow("\u26A0 Pro License and Terms of Service not yet accepted")),o.log(" License acceptance is required for using paid components"),o.log("")),o.log("License Details:"),o.log(` \u2022 Pro License: ${a.cyan("https://tiptap.dev/pro-license")}`),o.log(` \u2022 Terms of Service: ${a.cyan("https://tiptap.dev/terms-of-service")}`),o.log(""),o.log("About Paid Components:"),o.log(" Some paid UI components or templates are limited to specific plans."),o.log(" The license is valid during your trial period and active subscription."),o.log(""),e&&(o.log(a.gray("Available commands:")),o.log(a.gray(` \u2022 ${a.cyan("tiptap license forget me")} - Reset license acceptance`)),o.log(""))}async function fo(){if(!R.hasAcceptedLicense()){o.log(a.yellow("\u26A0 License has not been accepted yet"));return}await Pe("Are you sure you want to reset your license acceptance?",!1)?(R.clearLicenseAcceptance(),o.log(`${a.cyan("\u2714")} License acceptance has been reset`),o.log(" You will need to accept the license again when installing paid components")):o.log("License acceptance reset cancelled")}var pn=new ke().command("license").description("display Tiptap Pro license information and acceptance status").action(async()=>{try{await mo()}catch(e){_(e)}}).addCommand(new ke().command("forget me").description("reset license acceptance status").action(async()=>{try{await fo()}catch(e){_(e)}}));function uo(e){return e.some(t=>t.plans&&t.plans.some(n=>Ie.includes(n)))}async function go(e){if(e.filter(n=>n.plans&&n.plans.some(r=>Ie.includes(r))).length===0)return!0;if(R.hasAcceptedLicense())return o.log(`${a.cyan("\u2714")} Pro license accepted`),!0;o.log(""),o.log(a.yellow("\u{1F4CB} License Agreement")),o.log(""),o.log("Integrating paid components requires accepting:"),o.log(` \u2022 Pro License: ${a.cyan("https://tiptap.dev/pro-license")}`),o.log(` \u2022 Terms of Service: ${a.cyan("https://tiptap.dev/terms-of-service")}`),o.log(""),o.log(a.gray(" Valid during trial and active subscription")),o.log("");try{return await Pe("Do you accept the Pro license and terms of service?",!1)?(R.setLicenseAccepted(),o.log(`${a.cyan("\u2714")} License accepted`),!0):(o.log(a.gray("License not accepted")),o.log(a.gray("Tip: You can still install free components")),!1)}catch{return o.log(a.gray("License acceptance cancelled")),!1}}async function de(e,t){try{if(!uo(e))return!0;if((await xe()).authenticated){let s=await W(t);await ho(s,t)||await yo(s,t)}else{if(o.log(""),o.log(a.yellow("\u{1F510} Authentication Required")),o.log(""),o.log("Pro components require authentication."),o.log(`Run ${a.cyan("tiptap login")} or create an account at ${a.cyan("https://cloud.tiptap.dev")}`),o.log(""),!await Pe("Would you like to login now?",!0))return o.log(""),o.log(a.gray("Authentication cancelled")),o.log(a.gray("Tip: You can still install free components")),!1;if(!await gt({cwd:t,writeConfig:!0,showMessage:!1}))return!1}return!!await go(e)}catch(n){return o.error(`Authentication check failed: ${n instanceof Error?n.message:"Unknown error"}`),!1}}async function ho(e,t){try{return!!await Ue(e,t)}catch{return!1}}async function yo(e,t){let n=S("Creating registry configuration...")?.start();try{if(!(await xe()).authenticated)return n?.fail("Cannot create configuration - user not authenticated"),!1;let s=R.getAuthToken();if(!s)return n?.fail("No authentication token found"),!1;if(!await Oe(s,e,t))return n?.fail("Failed to save authentication token"),!1;n?.stopAndPersist({symbol:a.cyan("\u2714"),text:".npmrc created successfully"})}catch(r){n?.fail("Failed to create registry configuration"),o.error(`Configuration error: ${r instanceof Error?r.message:"Unknown error"}`)}}import Me from"process";function mn(){return Me.stdout.columns||80}function dn(e,t,n){let r=n?.borderColor||"gray",s=n?.padding!==!1,i="",c="",l="",p="",x="-",y="",w=mn(),u=Math.min(w-4,80),m=a[r],N=m(i+x.repeat(u-2)+c),b=m(l+x.repeat(u-2)+p),$=m(y),v=[];s&&v.push(""),v.push(N),v.push(`${$}${" ".repeat(u-2)}${$}`);let I=Math.floor((u-4-ht(e).length)/2),O=e.padStart(I+ht(e).length).padEnd(u-4);return v.push(`${$} ${O} ${$}`),v.push(`${$}${" ".repeat(u-2)}${$}`),t.forEach(U=>{let d=ht(U).length,f=u-4-d,k=U+" ".repeat(Math.max(0,f));v.push(`${$} ${k} ${$}`)}),t.length>0&&v.push(`${$}${" ".repeat(u-2)}${$}`),v.push(b),s&&v.push(""),v}function Be(e,t){let n=t?[t]:[];return dn(`${e}`,n,{borderColor:"gray"})}function yt(e,t){return dn(`\u26A0\uFE0F ${e}`,t,{borderColor:"yellow"})}function Y(e){e.forEach(t=>o.log(t))}function ht(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function We(e,t){let n=[];return n.push(""),n.push(a.cyan(e)),n.push(""),t.forEach(r=>{n.push(` \u2022 ${r}`)}),n.push(""),n}function ze(){Me.stdout.write("\x1B[2J\x1B[0f"),Me.platform==="win32"&&Me.stdout.write("\x1B[2J\x1B[3J\x1B[H")}function wt(){let e=Math.min(mn()-4,80);return a.gray("-".repeat(e))}import{existsSync as fn}from"fs";import un from"path";function wo(e){let t=e.name;return t===g["next-app"].name||t===g["next-pages"].name?"NEXT_PUBLIC_":t===g.astro.name?"PUBLIC_":t===g.vite.name||t===g["tanstack-start"].name||t===g["react-router"].name?"VITE_":(t===g.laravel.name||t===g.manual.name,"")}function gn(e){if(!e?.resolvedPaths?.styles)return"scss";let t=e.resolvedPaths.styles,n=un.join(t,"_variables.scss"),r=un.join(t,"_variables.css");return fn(r)?"css":(fn(n),"scss")}function hn(e,t){let n=e?.name||"unknown",r=t?.resolvedPaths?.styles?.includes("/src/"),s=t?.resolvedPaths?.components?.includes("/src/"),i="your main CSS file",c="./styles/";switch(n){case g["next-app"].name:s?(i="src/app/globals.css",c="../styles/"):r?(i="app/globals.css",c="../src/styles/"):(i="app/globals.css",c="../styles/");break;case g["next-pages"].name:s||r?(i="src/styles/globals.css",c="./"):(i="styles/globals.css",c="./");break;case g.vite.name:i="src/index.css",c="./styles/";break;case g["react-router"].name:i="src/index.css",c="./styles/";break;case g["tanstack-start"].name:i="src/index.css",c="./styles/";break;case g.astro.name:r?(i="src/layouts/Layout.astro",c="../styles/"):(i="src/layouts/Layout.astro",c="../../styles/");break;case g.laravel.name:i="resources/css/app.css",c="../styles/";break;case g.manual.name:default:s||r?(i="src/index.css",c="./styles/"):(i="your main CSS file",c="./styles/");break}return{cssFile:i,importPath:c}}function fe(e,t){let n=gn(t),{cssFile:r,importPath:s}=hn(e,t);console.log({framework:e,config:t,fileExtension:n,cssFile:r,importPath:s});let i=["The editor requires these style imports:","",`Add to ${a.cyan(r)}:`,"",a.yellow(` @import '${s}_variables.${n}';`),a.yellow(` @import '${s}_keyframe-animations.${n}';`),"","Without these imports, the editor will not display correctly.","",`Setup guide: ${a.cyan("https://tiptap.dev/docs/ui-components/getting-started/style")}`],c=yt("Action Required: Import Styles",i);Y(c)}function Ke(e,t){let n=wo(e),r=gn(t),{cssFile:s,importPath:i}=hn(e,t),c=["The Notion-like template is a complete editor application that requires","additional configuration before it can be used:","",a.cyan("1. Import Required Styles"),` Add to ${a.yellow(s)}:`,a.gray(` @import '${i}_variables.${r}';`),a.gray(` @import '${i}_keyframe-animations.${r}';`),"",a.cyan("2. Add Environment Variables (for collaborative features)")," Add to your .env file:",a.gray(` ${n}TIPTAP_COLLAB_DOC_PREFIX - Document prefix`),a.gray(` ${n}TIPTAP_COLLAB_APP_ID - Document Server App ID`),a.gray(` ${n}TIPTAP_COLLAB_TOKEN - JWT token for collaboration`),a.gray(` ${n}TIPTAP_AI_APP_ID - AI App ID`),a.gray(` ${n}TIPTAP_AI_TOKEN - JWT token for AI`),"",`Get credentials at ${a.cyan("https://cloud.tiptap.dev")}`,`Setup guide: ${a.cyan("https://tiptap.dev/docs/ui-components/templates/notion-like-editor")}`],l=yt("Next Steps: Configure your Editor",c);Y(l)}var vo=ie.object({components:ie.array(ie.string()).optional(),cwd:ie.string(),path:ie.string().optional(),silent:ie.boolean(),overwrite:ie.boolean()}),bo=1e3,Te={emptyRegistry:a.red("\u274C No components or templates found"),operationCancelled:a.gray("Operation cancelled"),missingDirectory:a.red("\u274C Directory not found. Use init to initialize a project first.")},kt={icon:{cursor:a.cyan("\u25B8"),checked:a.cyan("\u25C9"),unchecked:"\u25CB"},style:{highlight:e=>a.cyan(e),message:e=>e,answer:e=>""},prefix:{done:a.cyan("\u2714"),idle:a.cyan("?")}};function So(e,t){return t?e.filter(n=>t.includes(n.name)):e}function Pt(e){for(let t=0;t<e;t++)process.stdout.write("\x1B[1A"),process.stdout.write("\x1B[2K")}var Io=e=>({templates:e.filter(t=>t.type==="registry:template"),ui:e.filter(t=>t.type==="registry:ui"),primitives:e.filter(t=>t.type==="registry:ui-primitive"),uiUtils:e.filter(t=>t.type==="registry:ui-utils"),nodes:e.filter(t=>t.type==="registry:node")});async function Co(e,t=!0){let n="What would you like to integrate?",r=[],s=e.ui.length===0&&e.nodes.length===0;if(e.templates.length===0||r.push({name:"Templates - Full editor applications",value:"templates"}),s||r.push({name:"UI Components - Individual editor building blocks",value:"components"}),r.length===0)return o.break(),console.log(Te.emptyRegistry),null;try{t&&console.log(wt());let c=await ge({message:a.reset(n),pageSize:bo,theme:kt,choices:r});return t&&console.log(wt()),c}catch{return Pt(4),console.log(Te.operationCancelled),null}}async function Ao(e,t){let n=[];if(!t)return n;let r=(s,i)=>{let c=s.filter(l=>t.includes(l.name));c.length>0&&(n.push(new xt("")),n.push(new xt(a.gray(` ${i}`))),c.forEach(l=>{let p=l.plans&&l.plans.length?l.plans.includes("light")?"Open Source":"Available from Start plan":"Free",y=ye(l.name).padEnd(35);n.push({name:`${y} ${a.gray(p)}`,value:l.name})}),n.push(new xt(" ")))};return r(e.ui,"UI COMPONENTS"),r(e.nodes,"NODE COMPONENTS"),r(e.primitives,"PRIMITIVES"),n}async function Eo(e,t){let n=await Ao(e,t);if(n.length===0)return[];try{o.log(""),o.log(a.gray(" Use Space to select \u2022 A to toggle all \u2022 Enter to confirm"));let r=await To({message:"Choose UI components to install:",pageSize:20,choices:n,theme:kt});return r&&r.length>0&&(o.log(""),o.log(a.cyan("Selected components:")),r.forEach(s=>{o.log(` ${a.cyan("\u2022")} ${ye(s)}`)})),o.log(""),r||[]}catch{return Pt(25),console.log(Te.operationCancelled),[]}}async function Ro(e){try{let t=e.map(r=>{let s=r.plans&&r.plans.length?r.plans.includes("light")?"Open Source":"Available from Start plan":"Free",i=ye(r.name),c=r.description?` - ${r.description}`:"";return{name:`${`${i}${c}`.padEnd(50)} ${a.gray(s)}`,value:r.name}});o.log("");let n=await ge({message:"Choose an editor template to install:",pageSize:20,choices:t,theme:kt});return n&&(o.log(""),o.log(a.cyan("Selected template:")),o.log(` ${a.cyan("\u2022")} ${ye(n)}`)),o.log(""),n?[n]:[]}catch{return Pt(25),console.log(Te.operationCancelled),[]}}async function Tt(e,t=!0){if(e.components?.length)return e.components;let n;try{n=await X()}catch(c){if(c instanceof Error&&c.message.includes("You are not authorized")){if(!await de([{name:"unknown",plans:["start"]}],e.cwd))return o.error("Authentication failed. Cannot proceed with component selection."),[];try{n=await X()}catch{return o.break(),_(new Error("[prompts] - Failed to fetch registry index after authentication.")),[]}}else return o.break(),_(c),[]}if(!n)return o.break(),_(new Error("[prompts] - Failed to fetch registry index.")),[];let r=Io(n),s=await Co(r,t);if(!s)return[];let i=n.filter(c=>!(c.hide??!1)).map(c=>c.name);switch(s){case"components":return await Eo(r,i)||[];case"templates":{let c=So(r.templates,i);return await Ro(c)||[]}default:return[]}}var yn=new ko().name("add").description("add Tiptap UI components or templates as source code to your project").argument("[components...]","the components to add").option("-o, --overwrite","overwrite existing files.",!1).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-p, --path <path>","the path to add the component to.").option("-s, --silent","mute output.",!1).action(async(e,t)=>{try{ze();let n=Be("Tiptap UI Components","Install UI components or templates as editable source code in your project");Y(n);let r=We("What are Tiptap UI Components?",["React UI components that help you develop an editor","They install as source code (not npm packages) in your src/components/","UI components are a foundation for customization rather than a fixed library"]);Y(r),await Po({message:a.reset(`Press ${a.cyan("Enter")} to add components or templates...`),theme:{prefix:{done:"",idle:""}}}),o.log(""),o.log(""),o.log("");let s=vo.parse({components:e,cwd:xo.resolve(t.cwd),...t});if(s.components?.length||(s.components=await Tt(s)),!s.components?.length)return;let i=await X();if(!i)throw new Error("Failed to fetch registry index.");let c=s.components.map(w=>{let u=i.find(m=>m.name===w);return{name:w,plans:u?.plans||[]}});await de(c,s.cwd)||(o.error("Authentication failed. Cannot proceed with paid component download."),o.log("You can try again with only free components, or authenticate first."),process.exit(1));let{errors:p,config:x}=await Ut(s);if(p["1"]&&(o.warn(`
|
|
29
|
+
Registry Auth Token: ${a.cyan(l.tokens.authToken)}`),o.log("This token should be added to your project's configuration:"),await co(c,l.tokens.authToken,i)),s&&o.log("Bearer token saved globally for CLI authentication"),!0):(o.error("Authentication failed: "+l.error),!1)}async function po(e){let t=await W(e),n=await xe();if(n.authenticated){if(o.success(`Authenticated as ${a.cyan(n.user??"unknown user")}`),n.plans&&n.plans.length>0?n.plans.length===1?o.log(`Plan: ${a.cyan(n.plans[0])}`):o.log(`Plans: ${a.cyan(n.plans.join(", "))}`):o.log(`Plans: ${a.cyan("No active plans")}`),n.expires){let s=new Date(n.expires),i=new Date,c=Math.ceil((s.getTime()-i.getTime())/(1e3*60*60*24));c>30?o.log(`Token expires: ${a.cyan(s.toDateString())} (${c} days)`):c>0?o.log(`Token expires: ${a.yellow(s.toDateString())} (${c} days)`):o.log(`Token expires: ${a.red("Expired")}`)}if(n.token){let s=n.token.substring(0,10)+"...";o.log(`Bearer token: ${a.cyan(s)}`)}let r=await Ue(t,e);if(r){let s=r.substring(0,10)+"...";o.log(`Registry token: ${a.cyan(s)}`)}else o.log(`Registry token: ${a.yellow("Not configured for this project")}`),o.log(`Run ${a.cyan("@tiptap/cli login --write-config")} to configure for this project`)}else o.log("Not authenticated with Tiptap registry"),o.log(`Run ${a.cyan("@tiptap/cli login")} to authenticate`)}var an=new ke().command("login").description("log in to your Tiptap Cloud account").option("-e, --email <email>","your account email").option("-p, --password <password>","your account password").option("--write-config","write the auth token to your package manager config",void 0).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async e=>{try{let t=sn.parse(e);await gt(t)}catch(t){_(t)}}),cn=new ke().command("status").description("review your Tiptap Cloud authentication status").description("log out from your Tiptap registry account").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async e=>{let t=sn.parse(e),{cwd:n}=t;try{await po(n)}catch(r){_(r)}}),ln=new ke().command("logout").description("log out from your Tiptap registry account").action(async()=>{try{let e=S("Logging out...")?.start(),t=await on();t.success?e?.stopAndPersist({symbol:a.cyan("\u2714"),text:"Successfully logged out"}):(e?.fail("Logout failed"),o.error("Logout failed: "+t.error))}catch(e){_(e)}});async function mo(){o.log(""),o.log(a.yellow("\u{1F4CB} Tiptap Pro License Information")),o.log("");let e=R.hasAcceptedLicense(),t=R.getUserInfo();e?(o.log(`${a.cyan("\u2714")} Pro License and Terms of Service accepted`),t.email&&o.log(` Accepted by: ${a.cyan(t.email)}`),o.log("")):(o.log(a.yellow("\u26A0 Pro License and Terms of Service not yet accepted")),o.log(" License acceptance is required for using paid components"),o.log("")),o.log("License Details:"),o.log(` \u2022 Pro License: ${a.cyan("https://tiptap.dev/pro-license")}`),o.log(` \u2022 Terms of Service: ${a.cyan("https://tiptap.dev/terms-of-service")}`),o.log(""),o.log("About Paid Components:"),o.log(" Some paid UI components or templates are limited to specific plans."),o.log(" The license is valid during your trial period and active subscription."),o.log(""),e&&(o.log(a.gray("Available commands:")),o.log(a.gray(` \u2022 ${a.cyan("tiptap license forget me")} - Reset license acceptance`)),o.log(""))}async function fo(){if(!R.hasAcceptedLicense()){o.log(a.yellow("\u26A0 License has not been accepted yet"));return}await Pe("Are you sure you want to reset your license acceptance?",!1)?(R.clearLicenseAcceptance(),o.log(`${a.cyan("\u2714")} License acceptance has been reset`),o.log(" You will need to accept the license again when installing paid components")):o.log("License acceptance reset cancelled")}var pn=new ke().command("license").description("display Tiptap Pro license information and acceptance status").action(async()=>{try{await mo()}catch(e){_(e)}}).addCommand(new ke().command("forget me").description("reset license acceptance status").action(async()=>{try{await fo()}catch(e){_(e)}}));function uo(e){return e.some(t=>t.plans&&t.plans.some(n=>Ie.includes(n)))}async function go(e){if(e.filter(n=>n.plans&&n.plans.some(r=>Ie.includes(r))).length===0)return!0;if(R.hasAcceptedLicense())return o.log(`${a.cyan("\u2714")} Pro license accepted`),!0;o.log(""),o.log(a.yellow("\u{1F4CB} License Agreement")),o.log(""),o.log("Integrating paid components requires accepting:"),o.log(` \u2022 Pro License: ${a.cyan("https://tiptap.dev/pro-license")}`),o.log(` \u2022 Terms of Service: ${a.cyan("https://tiptap.dev/terms-of-service")}`),o.log(""),o.log(a.gray(" Valid during trial and active subscription")),o.log("");try{return await Pe("Do you accept the Pro license and terms of service?",!1)?(R.setLicenseAccepted(),o.log(`${a.cyan("\u2714")} License accepted`),!0):(o.log(a.gray("License not accepted")),o.log(a.gray("Tip: You can still install free components")),!1)}catch{return o.log(a.gray("License acceptance cancelled")),!1}}async function de(e,t){try{if(!uo(e))return!0;if((await xe()).authenticated){let s=await W(t);await ho(s,t)||await yo(s,t)}else{if(o.log(""),o.log(a.yellow("\u{1F510} Authentication Required")),o.log(""),o.log("Pro components require authentication."),o.log(`Run ${a.cyan("tiptap login")} or create an account at ${a.cyan("https://cloud.tiptap.dev")}`),o.log(""),!await Pe("Would you like to login now?",!0))return o.log(""),o.log(a.gray("Authentication cancelled")),o.log(a.gray("Tip: You can still install free components")),!1;if(!await gt({cwd:t,writeConfig:!0,showMessage:!1}))return!1}return!!await go(e)}catch(n){return o.error(`Authentication check failed: ${n instanceof Error?n.message:"Unknown error"}`),!1}}async function ho(e,t){try{return!!await Ue(e,t)}catch{return!1}}async function yo(e,t){let n=S("Creating registry configuration...")?.start();try{if(!(await xe()).authenticated)return n?.fail("Cannot create configuration - user not authenticated"),!1;let s=R.getAuthToken();if(!s)return n?.fail("No authentication token found"),!1;if(!await Oe(s,e,t))return n?.fail("Failed to save authentication token"),!1;n?.stopAndPersist({symbol:a.cyan("\u2714"),text:".npmrc created successfully"})}catch(r){n?.fail("Failed to create registry configuration"),o.error(`Configuration error: ${r instanceof Error?r.message:"Unknown error"}`)}}import Me from"process";function mn(){return Me.stdout.columns||80}function dn(e,t,n){let r=n?.borderColor||"gray",s=n?.padding!==!1,i="",c="",l="",p="",x="-",y="",w=mn(),u=Math.min(w-4,80),m=a[r],N=m(i+x.repeat(u-2)+c),b=m(l+x.repeat(u-2)+p),$=m(y),v=[];s&&v.push(""),v.push(N),v.push(`${$}${" ".repeat(u-2)}${$}`);let I=Math.floor((u-4-ht(e).length)/2),O=e.padStart(I+ht(e).length).padEnd(u-4);return v.push(`${$} ${O} ${$}`),v.push(`${$}${" ".repeat(u-2)}${$}`),t.forEach(U=>{let d=ht(U).length,f=u-4-d,k=U+" ".repeat(Math.max(0,f));v.push(`${$} ${k} ${$}`)}),t.length>0&&v.push(`${$}${" ".repeat(u-2)}${$}`),v.push(b),s&&v.push(""),v}function Be(e,t){let n=t?[t]:[];return dn(`${e}`,n,{borderColor:"gray"})}function yt(e,t){return dn(`\u26A0\uFE0F ${e}`,t,{borderColor:"yellow"})}function Y(e){e.forEach(t=>o.log(t))}function ht(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function We(e,t){let n=[];return n.push(""),n.push(a.cyan(e)),n.push(""),t.forEach(r=>{n.push(` \u2022 ${r}`)}),n.push(""),n}function ze(){Me.stdout.write("\x1B[2J\x1B[0f"),Me.platform==="win32"&&Me.stdout.write("\x1B[2J\x1B[3J\x1B[H")}function wt(){let e=Math.min(mn()-4,80);return a.gray("-".repeat(e))}import{existsSync as fn}from"fs";import un from"path";function wo(e){let t=e.name;return t===g["next-app"].name||t===g["next-pages"].name?"NEXT_PUBLIC_":t===g.astro.name?"PUBLIC_":t===g.vite.name||t===g["tanstack-start"].name||t===g["react-router"].name?"VITE_":(t===g.laravel.name||t===g.manual.name,"")}function gn(e){if(!e?.resolvedPaths?.styles)return"scss";let t=e.resolvedPaths.styles,n=un.join(t,"_variables.scss"),r=un.join(t,"_variables.css");return fn(r)?"css":(fn(n),"scss")}function hn(e,t){let n=e?.name||"unknown",r=t?.resolvedPaths?.styles?.includes("/src/"),s=t?.resolvedPaths?.components?.includes("/src/"),i="your main CSS file",c="./styles/";switch(n){case g["next-app"].name:s?(i="src/app/globals.css",c="../styles/"):r?(i="app/globals.css",c="../src/styles/"):(i="app/globals.css",c="../styles/");break;case g["next-pages"].name:s||r?(i="src/styles/globals.css",c="./"):(i="styles/globals.css",c="./");break;case g.vite.name:i="src/index.css",c="./styles/";break;case g["react-router"].name:i="src/index.css",c="./styles/";break;case g["tanstack-start"].name:i="src/index.css",c="./styles/";break;case g.astro.name:r?(i="src/layouts/Layout.astro",c="../styles/"):(i="src/layouts/Layout.astro",c="../../styles/");break;case g.laravel.name:i="resources/css/app.css",c="../styles/";break;case g.manual.name:default:s||r?(i="src/index.css",c="./styles/"):(i="your main CSS file",c="./styles/");break}return{cssFile:i,importPath:c}}function fe(e,t){let n=gn(t),{cssFile:r,importPath:s}=hn(e,t),i=["The editor requires these style imports:","",`Add to ${a.cyan(r)}:`,"",a.yellow(` @import '${s}_variables.${n}';`),a.yellow(` @import '${s}_keyframe-animations.${n}';`),"","Without these imports, the editor will not display correctly.","",`Setup guide: ${a.cyan("https://tiptap.dev/docs/ui-components/getting-started/style")}`],c=yt("Action Required: Import Styles",i);Y(c)}function Ke(e,t){let n=wo(e),r=gn(t),{cssFile:s,importPath:i}=hn(e,t),c=["The Notion-like template is a complete editor application that requires","additional configuration before it can be used:","",a.cyan("1. Import Required Styles"),` Add to ${a.yellow(s)}:`,a.gray(` @import '${i}_variables.${r}';`),a.gray(` @import '${i}_keyframe-animations.${r}';`),"",a.cyan("2. Add Environment Variables (for collaborative features)")," Add to your .env file:",a.gray(` ${n}TIPTAP_COLLAB_DOC_PREFIX - Document prefix`),a.gray(` ${n}TIPTAP_COLLAB_APP_ID - Document Server App ID`),a.gray(` ${n}TIPTAP_COLLAB_TOKEN - JWT token for collaboration`),a.gray(` ${n}TIPTAP_AI_APP_ID - AI App ID`),a.gray(` ${n}TIPTAP_AI_TOKEN - JWT token for AI`),"",`Get credentials at ${a.cyan("https://cloud.tiptap.dev")}`,`Setup guide: ${a.cyan("https://tiptap.dev/docs/ui-components/templates/notion-like-editor")}`],l=yt("Next Steps: Configure your Editor",c);Y(l)}var vo=ie.object({components:ie.array(ie.string()).optional(),cwd:ie.string(),path:ie.string().optional(),silent:ie.boolean(),overwrite:ie.boolean()}),bo=1e3,Te={emptyRegistry:a.red("\u274C No components or templates found"),operationCancelled:a.gray("Operation cancelled"),missingDirectory:a.red("\u274C Directory not found. Use init to initialize a project first.")},kt={icon:{cursor:a.cyan("\u25B8"),checked:a.cyan("\u25C9"),unchecked:"\u25CB"},style:{highlight:e=>a.cyan(e),message:e=>e,answer:e=>""},prefix:{done:a.cyan("\u2714"),idle:a.cyan("?")}};function So(e,t){return t?e.filter(n=>t.includes(n.name)):e}function Pt(e){for(let t=0;t<e;t++)process.stdout.write("\x1B[1A"),process.stdout.write("\x1B[2K")}var Io=e=>({templates:e.filter(t=>t.type==="registry:template"),ui:e.filter(t=>t.type==="registry:ui"),primitives:e.filter(t=>t.type==="registry:ui-primitive"),uiUtils:e.filter(t=>t.type==="registry:ui-utils"),nodes:e.filter(t=>t.type==="registry:node")});async function Co(e,t=!0){let n="What would you like to integrate?",r=[],s=e.ui.length===0&&e.nodes.length===0;if(e.templates.length===0||r.push({name:"Templates - Full editor applications",value:"templates"}),s||r.push({name:"UI Components - Individual editor building blocks",value:"components"}),r.length===0)return o.break(),console.log(Te.emptyRegistry),null;try{t&&console.log(wt());let c=await ge({message:a.reset(n),pageSize:bo,theme:kt,choices:r});return t&&console.log(wt()),c}catch{return Pt(4),console.log(Te.operationCancelled),null}}async function Ao(e,t){let n=[];if(!t)return n;let r=(s,i)=>{let c=s.filter(l=>t.includes(l.name));c.length>0&&(n.push(new xt("")),n.push(new xt(a.gray(` ${i}`))),c.forEach(l=>{let p=l.plans&&l.plans.length?l.plans.includes("light")?"Open Source":"Available from Start plan":"Free",y=ye(l.name).padEnd(35);n.push({name:`${y} ${a.gray(p)}`,value:l.name})}),n.push(new xt(" ")))};return r(e.ui,"UI COMPONENTS"),r(e.nodes,"NODE COMPONENTS"),r(e.primitives,"PRIMITIVES"),n}async function Eo(e,t){let n=await Ao(e,t);if(n.length===0)return[];try{o.log(""),o.log(a.gray(" Use Space to select \u2022 A to toggle all \u2022 Enter to confirm"));let r=await To({message:"Choose UI components to install:",pageSize:20,choices:n,theme:kt});return r&&r.length>0&&(o.log(""),o.log(a.cyan("Selected components:")),r.forEach(s=>{o.log(` ${a.cyan("\u2022")} ${ye(s)}`)})),o.log(""),r||[]}catch{return Pt(25),console.log(Te.operationCancelled),[]}}async function Ro(e){try{let t=e.map(r=>{let s=r.plans&&r.plans.length?r.plans.includes("light")?"Open Source":"Available from Start plan":"Free",i=ye(r.name),c=r.description?` - ${r.description}`:"";return{name:`${`${i}${c}`.padEnd(50)} ${a.gray(s)}`,value:r.name}});o.log("");let n=await ge({message:"Choose an editor template to install:",pageSize:20,choices:t,theme:kt});return n&&(o.log(""),o.log(a.cyan("Selected template:")),o.log(` ${a.cyan("\u2022")} ${ye(n)}`)),o.log(""),n?[n]:[]}catch{return Pt(25),console.log(Te.operationCancelled),[]}}async function Tt(e,t=!0){if(e.components?.length)return e.components;let n;try{n=await X()}catch(c){if(c instanceof Error&&c.message.includes("You are not authorized")){if(!await de([{name:"unknown",plans:["start"]}],e.cwd))return o.error("Authentication failed. Cannot proceed with component selection."),[];try{n=await X()}catch{return o.break(),_(new Error("[prompts] - Failed to fetch registry index after authentication.")),[]}}else return o.break(),_(c),[]}if(!n)return o.break(),_(new Error("[prompts] - Failed to fetch registry index.")),[];let r=Io(n),s=await Co(r,t);if(!s)return[];let i=n.filter(c=>!(c.hide??!1)).map(c=>c.name);switch(s){case"components":return await Eo(r,i)||[];case"templates":{let c=So(r.templates,i);return await Ro(c)||[]}default:return[]}}var yn=new ko().name("add").description("add Tiptap UI components or templates as source code to your project").argument("[components...]","the components to add").option("-o, --overwrite","overwrite existing files.",!1).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-p, --path <path>","the path to add the component to.").option("-s, --silent","mute output.",!1).action(async(e,t)=>{try{ze();let n=Be("Tiptap UI Components","Install UI components or templates as editable source code in your project");Y(n);let r=We("What are Tiptap UI Components?",["React UI components that help you develop an editor","They install as source code (not npm packages) in your src/components/","UI components are a foundation for customization rather than a fixed library"]);Y(r),await Po({message:a.reset(`Press ${a.cyan("Enter")} to add components or templates...`),theme:{prefix:{done:"",idle:""}}}),o.log(""),o.log(""),o.log("");let s=vo.parse({components:e,cwd:xo.resolve(t.cwd),...t});if(s.components?.length||(s.components=await Tt(s)),!s.components?.length)return;let i=await X();if(!i)throw new Error("Failed to fetch registry index.");let c=s.components.map(w=>{let u=i.find(m=>m.name===w);return{name:w,plans:u?.plans||[]}});await de(c,s.cwd)||(o.error("Authentication failed. Cannot proceed with paid component download."),o.log("You can try again with only free components, or authenticate first."),process.exit(1));let{errors:p,config:x}=await Ut(s);if(p["1"]&&(o.warn(`
|
|
30
30
|
${Te.missingDirectory}`),process.exit(0)),!x)throw new Error(`Failed to read config at ${a.cyan(s.cwd)}.`);let y=await je(s.components,x,s);if(y&&y.filesCreated.length>0){let w=y.filesCreated.some(m=>m.includes("notion")),u=y.filesCreated.some(m=>m.includes("simple")&&m.includes("editor"));if(w){o.log(""),o.log(`${a.green("\u2714")} Notion template installed - ${y.filesCreated.length} files added to ${a.cyan("src/components/")}`),o.log("");let m=await D(s.cwd);m&&Ke(m.framework,x)}else if(u){o.log(""),o.log(`${a.green("\u2714")} Simple editor template installed - ${y.filesCreated.length} files added to ${a.cyan("src/components/")}`),o.log("");let m=await D(s.cwd);m&&fe(m.framework,x)}else if(o.log(""),o.log(`${a.green("\u2714")} Components installed - ${y.filesCreated.length} files added to ${a.cyan("src/components/")}`),o.log(""),y.filesCreated.some(N=>N.includes("tiptap-templates")||N.includes("tiptap-ui"))){let N=await D(s.cwd);N&&fe(N.framework,x)}}}catch(n){o.break(),_(n)}});import{Command as $o}from"commander";var wn=new $o().name("info").description("get information about your project").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async e=>{o.info("> project info"),console.log(await D(e.cwd)),o.break();try{let t=await J(e.cwd);o.info("> config"),console.log(t)}catch{o.info("")}});import bn from"path";import{Command as Zo}from"commander";import{confirm as Qo,input as es}from"@inquirer/prompts";import{z as G}from"zod";import _o from"path";import kn from"fs-extra";async function Pn(e){let t={};if(!kn.existsSync(e.cwd)||!kn.existsSync(_o.resolve(e.cwd,"package.json")))return t["1"]=!0,{errors:t,projectInfo:null};let n=S("Verifying framework.",{silent:e.silent}).start(),r=await D(e.cwd);(!r||r?.framework.name==="manual")&&(t["7"]=!0,n?.fail(),o.break(),r?.framework.links.installation&&o.error(`We could not detect a supported framework at ${a.cyan(e.cwd)}.
|
|
31
31
|
Visit ${a.cyan(r?.framework.links.installation)} to manually configure your project.
|
|
32
32
|
Once configured, you can use the cli to add components.`),o.break(),process.exit(0)),n?.stopAndPersist({symbol:a.cyan("\u2714"),text:`Verifying framework. Found ${a.cyan(r.framework.label)}.`});let s=S("Validating import alias.",{silent:e.silent}).start();return r?.aliasPrefix?s?.stopAndPersist({symbol:a.cyan("\u2714")}):(t["6"]=!0,s?.fail()),Object.keys(t).length>0&&(t["6"]&&(o.break(),o.error("No import alias found in your tsconfig.json file."),r?.framework.links.installation&&o.error(`Visit ${a.cyan(r?.framework.links.installation)} to learn how to set an import alias.`)),o.break(),process.exit(0)),{errors:t,projectInfo:r}}import jo from"os";import Z from"path";import z from"fs-extra";import{execa as V}from"execa";import{parse as Oo}from"jsonc-parser";import{input as Uo}from"@inquirer/prompts";var Do="https://codeload.github.com/shadcn-ui/ui/tar.gz/main",ue={next:"next",vite:"vite","next-monorepo":"next-monorepo"},Fo=(e,t="")=>Uo({message:a.reset(e),default:t,required:!0,validate:n=>n.length>128?"Name should be less than 128 characters.":!0,theme:{prefix:{done:a.cyan("\u2714"),idle:"?"}}}),Lo=async(e,t)=>{let n=`
|
|
@@ -341,5 +341,5 @@ The built-in AI tools let you:
|
|
|
341
341
|
|
|
342
342
|
## Extendability
|
|
343
343
|
|
|
344
|
-
This template is designed to grow with your needs. New Tiptap Cloud features will be seamlessly compatible with the same UI system\u2014no rewrites required.`;async function vn(e,t){let n=Z.join(e,"README.md"),r={"simple-editor":Ho,"notion-like-editor":Xo},s=t&&t in r?r[t]:"";try{s.trim()&&await z.writeFile(n,s,"utf-8")}catch{}}var ts=G.object({cwd:G.string(),components:G.array(G.string()).optional(),silent:G.boolean(),isNewProject:G.boolean(),srcDir:G.boolean().optional(),reactCompiler:G.boolean().optional(),framework:G.string().optional().refine(e=>!e||ue[e],{message:"Invalid framework. Please use 'next' or 'vite'."})}),vt=(e,t=!0)=>Qo({message:a.reset(e),default:t,theme:{prefix:{done:a.cyan("\u2714"),idle:"?"}}}),Sn=new Zo().name("init").description("initialize your project and install Tiptap UI components as source code").argument("[components...]","the components to add").option("-f, --framework <framework>","the framework to use. (next, vite)").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-s, --silent","mute output.",!1).option("--src-dir","use the src directory when creating a new project (specific to next).",!1).option("--react-compiler","enable React Compiler when creating a new project (specific to next).",!1).action(async(e,t)=>{try{ze();let n=Be("Tiptap UI Components","Install UI components or templates as editable source code in your project");Y(n);let r=We("What are Tiptap UI Components?",["React UI components that help you develop an editor","They install as source code (not npm packages) in your src/components/","UI components are a foundation for customization rather than a fixed library"]);Y(r),await es({message:a.reset(`Press ${a.cyan("Enter")} to initialize a project...`),theme:{prefix:{done:"",idle:""}}}),o.log("");let s=ts.parse({cwd:bn.resolve(t.cwd),isNewProject:!1,components:e,...t}),i=await ns(s);if(i?.filesCreated&&i.filesCreated.length>0){let c=i.filesCreated.some(p=>p.includes("notion")),l=i.filesCreated.some(p=>p.includes("simple")&&p.includes("editor"));if(c){o.log(""),o.log(`${a.green("\u2714")} Notion template installed - ${i.filesCreated.length} files added to ${a.cyan("src/components/")}`),o.log("");let p=i.framework||i.projectInfo?.framework;p&&Ke(p,i.config)}else if(l){o.log(""),o.log(`${a.green("\u2714")} Simple editor template installed - ${i.filesCreated.length} files added to ${a.cyan("src/components/")}`),o.log("");let p=i.framework||i.projectInfo?.framework;p&&fe(p,i.config)}else o.log(""),o.log(`${a.green("\u2714")} Components installed - ${i.filesCreated.length} files added to ${a.cyan("src/components/")}`),o.log(""),i.filesCreated.some(x=>x.includes("tiptap-templates")||x.includes("tiptap-ui"))&&fe(i?.projectInfo?.framework,i.config)}o.break()}catch(n){o.break(),_(n)}});async function ns(e){let{cwd:t,skipPreflight:n,components:r,silent:s}=e,i={...e},c,l=(v,I,O=[],U)=>({config:v,projectInfo:I,framework:c,selectedComponents:O,filesCreated:U?.filesCreated||[],filesUpdated:U?.filesUpdated||[],filesSkipped:U?.filesSkipped||[],errors:[]}),p;if(n)p=await D(t);else{let v=await Pn(e);if(v.errors["1"]){let{projectPath:O,framework:U}=await Tn(e);O||process.exit(0),i={...i,cwd:O,isNewProject:!0},c=U,o.log("")}p=v.projectInfo}if(c==="next-monorepo"){let v=bn.resolve(i.cwd,"apps/web"),I=await J(v);return l(I,p)}let x=await Nt(i.cwd,p),y=x?await os(x):await rs(await J(i.cwd));o.log("");let w=r||[];if(!w.length){if(!await vt("Would you like to add a template or UI components to your project?")){let I=await ee(i.cwd,y);return l(I,p)}if(w=await Tt({...i,overwrite:!1},!0),!w.length){let I=await ee(i.cwd,y);return l(I,p)}}let u;try{if(u=await X(),!u)throw new Error("Failed to fetch registry index.")}catch(v){if(v instanceof Error&&v.message.includes("You are not authorized")){let I=w.map(U=>({name:U,plans:["start"]}));if(await de(I,i.cwd)||(o.error("Authentication failed. Cannot proceed with paid component download."),o.log("You can try again with only free components, or authenticate first."),process.exit(1)),u=await X(),!u)throw new Error("Failed to fetch registry index after authentication.")}else throw v}let m=w.map(v=>{let I=u.find(O=>O.name===v);return{name:v,plans:I?.plans||[]}});await de(m,i.cwd)||(o.error("Authentication failed. Cannot proceed with paid component download."),o.log("You can try again with only free components, or authenticate first."),process.exit(1));let b=await ee(i.cwd,y),$=await je(w,b,{overwrite:!1,silent:s,isNewProject:i.isNewProject||p?.framework.name==="next-app"});return l(b,p,w,$||{filesCreated:[],filesUpdated:[],filesSkipped:[]})}async function rs(e=null){o.log(""),o.log(a.cyan("Project Configuration")),o.log("");let t=await vt(`Would you like to use ${a.cyan("TypeScript")} (recommended)?`,e?.tsx??!0),n=await vt(`Are you using ${a.cyan("React Server Components")}?`,e?.rsc??!0);return te.parse({rsc:n,tsx:t,aliases:{components:Ge,contexts:He,hooks:Xe,tiptapIcons:Ze,lib:Se,tiptapExtensions:Qe,tiptapNodes:et,tiptapUi:tt,tiptapUiPrimitives:nt,tiptapUiUtils:rt,styles:ot}})}async function os(e){return te.parse({rsc:e?.rsc,tsx:e?.tsx,aliases:e?.aliases})}import{Command as is}from"commander";var In={name:"@tiptap/cli",version:"3.3.
|
|
344
|
+
This template is designed to grow with your needs. New Tiptap Cloud features will be seamlessly compatible with the same UI system\u2014no rewrites required.`;async function vn(e,t){let n=Z.join(e,"README.md"),r={"simple-editor":Ho,"notion-like-editor":Xo},s=t&&t in r?r[t]:"";try{s.trim()&&await z.writeFile(n,s,"utf-8")}catch{}}var ts=G.object({cwd:G.string(),components:G.array(G.string()).optional(),silent:G.boolean(),isNewProject:G.boolean(),srcDir:G.boolean().optional(),reactCompiler:G.boolean().optional(),framework:G.string().optional().refine(e=>!e||ue[e],{message:"Invalid framework. Please use 'next' or 'vite'."})}),vt=(e,t=!0)=>Qo({message:a.reset(e),default:t,theme:{prefix:{done:a.cyan("\u2714"),idle:"?"}}}),Sn=new Zo().name("init").description("initialize your project and install Tiptap UI components as source code").argument("[components...]","the components to add").option("-f, --framework <framework>","the framework to use. (next, vite)").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-s, --silent","mute output.",!1).option("--src-dir","use the src directory when creating a new project (specific to next).",!1).option("--react-compiler","enable React Compiler when creating a new project (specific to next).",!1).action(async(e,t)=>{try{ze();let n=Be("Tiptap UI Components","Install UI components or templates as editable source code in your project");Y(n);let r=We("What are Tiptap UI Components?",["React UI components that help you develop an editor","They install as source code (not npm packages) in your src/components/","UI components are a foundation for customization rather than a fixed library"]);Y(r),await es({message:a.reset(`Press ${a.cyan("Enter")} to initialize a project...`),theme:{prefix:{done:"",idle:""}}}),o.log("");let s=ts.parse({cwd:bn.resolve(t.cwd),isNewProject:!1,components:e,...t}),i=await ns(s);if(i?.filesCreated&&i.filesCreated.length>0){let c=i.filesCreated.some(p=>p.includes("notion")),l=i.filesCreated.some(p=>p.includes("simple")&&p.includes("editor"));if(c){o.log(""),o.log(`${a.green("\u2714")} Notion template installed - ${i.filesCreated.length} files added to ${a.cyan("src/components/")}`),o.log("");let p=i.framework||i.projectInfo?.framework;p&&Ke(p,i.config)}else if(l){o.log(""),o.log(`${a.green("\u2714")} Simple editor template installed - ${i.filesCreated.length} files added to ${a.cyan("src/components/")}`),o.log("");let p=i.framework||i.projectInfo?.framework;p&&fe(p,i.config)}else o.log(""),o.log(`${a.green("\u2714")} Components installed - ${i.filesCreated.length} files added to ${a.cyan("src/components/")}`),o.log(""),i.filesCreated.some(x=>x.includes("tiptap-templates")||x.includes("tiptap-ui"))&&fe(i?.projectInfo?.framework,i.config)}o.break()}catch(n){o.break(),_(n)}});async function ns(e){let{cwd:t,skipPreflight:n,components:r,silent:s}=e,i={...e},c,l=(v,I,O=[],U)=>({config:v,projectInfo:I,framework:c,selectedComponents:O,filesCreated:U?.filesCreated||[],filesUpdated:U?.filesUpdated||[],filesSkipped:U?.filesSkipped||[],errors:[]}),p;if(n)p=await D(t);else{let v=await Pn(e);if(v.errors["1"]){let{projectPath:O,framework:U}=await Tn(e);O||process.exit(0),i={...i,cwd:O,isNewProject:!0},c=U,o.log("")}p=v.projectInfo}if(c==="next-monorepo"){let v=bn.resolve(i.cwd,"apps/web"),I=await J(v);return l(I,p)}let x=await Nt(i.cwd,p),y=x?await os(x):await rs(await J(i.cwd));o.log("");let w=r||[];if(!w.length){if(!await vt("Would you like to add a template or UI components to your project?")){let I=await ee(i.cwd,y);return l(I,p)}if(w=await Tt({...i,overwrite:!1},!0),!w.length){let I=await ee(i.cwd,y);return l(I,p)}}let u;try{if(u=await X(),!u)throw new Error("Failed to fetch registry index.")}catch(v){if(v instanceof Error&&v.message.includes("You are not authorized")){let I=w.map(U=>({name:U,plans:["start"]}));if(await de(I,i.cwd)||(o.error("Authentication failed. Cannot proceed with paid component download."),o.log("You can try again with only free components, or authenticate first."),process.exit(1)),u=await X(),!u)throw new Error("Failed to fetch registry index after authentication.")}else throw v}let m=w.map(v=>{let I=u.find(O=>O.name===v);return{name:v,plans:I?.plans||[]}});await de(m,i.cwd)||(o.error("Authentication failed. Cannot proceed with paid component download."),o.log("You can try again with only free components, or authenticate first."),process.exit(1));let b=await ee(i.cwd,y),$=await je(w,b,{overwrite:!1,silent:s,isNewProject:i.isNewProject||p?.framework.name==="next-app"});return l(b,p,w,$||{filesCreated:[],filesUpdated:[],filesSkipped:[]})}async function rs(e=null){o.log(""),o.log(a.cyan("Project Configuration")),o.log("");let t=await vt(`Would you like to use ${a.cyan("TypeScript")} (recommended)?`,e?.tsx??!0),n=await vt(`Are you using ${a.cyan("React Server Components")}?`,e?.rsc??!0);return te.parse({rsc:n,tsx:t,aliases:{components:Ge,contexts:He,hooks:Xe,tiptapIcons:Ze,lib:Se,tiptapExtensions:Qe,tiptapNodes:et,tiptapUi:tt,tiptapUiPrimitives:nt,tiptapUiUtils:rt,styles:ot}})}async function os(e){return te.parse({rsc:e?.rsc,tsx:e?.tsx,aliases:e?.aliases})}import{Command as is}from"commander";var In={name:"@tiptap/cli",version:"3.3.6",description:"Tiptap CLI",publishConfig:{access:"public"},author:{name:"tiptap",url:"https://github.com/ueberdosis/tiptap"},files:["dist"],keywords:["cli","components","nextjs","react","templates","tiptap","@tiptap/cli","ui"],license:"SEE LICENSE IN LICENSE.md",type:"module",exports:{".":{types:"./dist/index.d.ts",default:"./dist/index.js"}},bin:"./dist/index.js",scripts:{dev:"tsup --watch",build:"tsup",typecheck:"tsc --noEmit",clean:"rm -rf dist","start:dev":"cross-env REGISTRY_URL=http://localhost:3000 node dist/index.js","start:prod":"cross-env REGISTRY_URL=https://template.tiptap.dev node dist/index.js",start:"node dist/index.js","pub:beta":"pnpm build && pnpm publish --no-git-checks --access public --tag beta","pub:release":"pnpm build && pnpm publish --access public"},dependencies:{"@antfu/ni":"^23.3.1","@babel/core":"^7.28.4","@babel/parser":"^7.28.4","@babel/plugin-transform-typescript":"^7.28.0","@inquirer/core":"^10.3.0","@inquirer/figures":"^1.0.14","@inquirer/prompts":"^7.9.0","@inquirer/type":"^3.0.9","ansi-escapes":"^7.1.1",chalk:"^5.6.2",commander:"^13.1.0",conf:"^14.0.0",cosmiconfig:"^9.0.0",deepmerge:"^4.3.1",execa:"^9.6.0","fast-glob":"^3.3.3","fs-extra":"^11.3.2","https-proxy-agent":"^7.0.6","jsonc-parser":"^3.3.1","node-fetch":"^3.3.2",ora:"^8.2.0",recast:"^0.23.11",sass:"^1.93.2","ts-morph":"^25.0.1","tsconfig-paths":"^4.2.0",yaml:"^2.8.1","yoctocolors-cjs":"^2.1.3",zod:"^3.25.76"},devDependencies:{"@babel/plugin-transform-typescript":"^7.26.5","@types/babel__core":"^7.20.5","@types/conf":"^3.0.3","@types/fs-extra":"^11.0.4","@types/prompts":"^2.4.9","cross-env":"^7.0.3",tsup:"^8.5.0","type-fest":"^4.41.0"}};process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function as(){let e=new is().name("tiptap").description("add components and dependencies to your project").version(In.version||"1.0.0","-v, --version","display the CLI version number");e.addCommand(Sn).addCommand(yn).addCommand(wn).addCommand(an).addCommand(ln).addCommand(cn).addCommand(pn),e.parse()}as();
|
|
345
345
|
//# sourceMappingURL=index.js.map
|