11import chalk from 'chalk' ;
2- import { checkbox , confirm , input } from '@inquirer/prompts' ;
2+ import { checkbox , input , select } from '@inquirer/prompts' ;
33import { checkStrapiProject } from '../utils/strapi' ;
44import { getContentTypes , enableWebtoolsForContentType } from '../utils/content-types' ;
55import { getAvailableAddons , getPremiumAddons } from '../utils/addons' ;
66import { installPackage } from '../utils/package-manager' ;
77import { createLicenseFiles } from '../utils/license' ;
8+ import { logger } from '../utils/logger' ;
89
910export async function install ( ) {
1011 // Check if we're in a Strapi project
@@ -14,14 +15,30 @@ export async function install() {
1415 return ;
1516 }
1617
17- // Ask about license key
18- const hasLicense = await confirm ( {
19- message : 'Do you have a license key for Webtools?' ,
20- default : false ,
18+ logger . title (
19+ 'Webtools' ,
20+ `${ chalk . bold ( '🚀 Let\'s build your new website with Strapi' ) } \n` ,
21+ ) ;
22+
23+ console . log ( '🚀 Get more out of Webtools with premium add-ons!\n' ) ;
24+
25+ console . log ( 'Start your free trial and get:' ) ;
26+ console . log ( '✨ 30 days of access to the Essential plan, which includes:' ) ;
27+ console . log ( '✅ Automated Redirects' ) ;
28+ console . log ( '✅ Internal Links\n' ) ;
29+
30+ const selectedPlan = await select ( {
31+ message : 'Do you have a license?' ,
32+ choices : [
33+ { name : 'Yes, use my license' , value : 'license' } ,
34+ { name : 'Get me a trial' , value : 'trial' } ,
35+ { name : 'Skip' , value : 'skip' } ,
36+ ] ,
2137 } ) ;
2238
2339 let licenseKey : string | null = null ;
24- if ( hasLicense ) {
40+
41+ if ( selectedPlan === 'license' ) {
2542 licenseKey = await input ( {
2643 message : 'Please enter your license key:' ,
2744 validate : ( value ) => {
@@ -33,14 +50,53 @@ export async function install() {
3350 } ) ;
3451
3552 // Create license files
36- console . log ( chalk . blue ( '\nSetting up license configuration...' ) ) ;
53+ console . log ( `\n ${ chalk . cyan ( '●' ) } Setting up license configuration...` ) ;
3754 const success = await createLicenseFiles ( licenseKey ) ;
3855 if ( ! success ) {
39- console . log ( chalk . red ( 'Failed to setup license configuration. Continuing without the license.' ) ) ;
56+ console . log ( chalk . red ( '\nFailed to setup license configuration. Continuing without a license.' ) ) ;
4057 licenseKey = null ;
4158 }
4259 }
4360
61+ if ( selectedPlan === 'trial' ) {
62+ logger . title (
63+ 'Trial' ,
64+ `${ chalk . bold ( '🚀 Get your free trial license!' ) } \n` ,
65+ ) ;
66+ console . log ( 'You can start your free trial by visiting the following link:' ) ;
67+ console . log ( chalk . underline ( 'https://polar.sh/checkout/polar_c_4NUnsZ24PTLPhbSux9STPqeLL7ptZlcz003Yy15MArc' ) ) ;
68+ console . log ( '\n✨ Enjoy 30 days of access to the Essential plan completely free!' ) ;
69+ console . log ( '💡 Remember: You can cancel within the 30 days to ensure your trial remains free.\n' ) ;
70+
71+ const trialPlan = await select ( {
72+ message : 'Got your license key?' ,
73+ choices : [
74+ { name : 'Yes' , value : 'yes' } ,
75+ { name : 'Skip' , value : 'skip' } ,
76+ ] ,
77+ } ) ;
78+
79+ if ( trialPlan === 'yes' ) {
80+ licenseKey = await input ( {
81+ message : 'Please enter your license key:' ,
82+ validate : ( value ) => {
83+ if ( ! value || value . trim ( ) . length === 0 ) {
84+ return 'License key cannot be empty' ;
85+ }
86+ return true ;
87+ } ,
88+ } ) ;
89+
90+ // Create license files
91+ console . log ( `\n${ chalk . cyan ( '●' ) } Setting up license configuration...` ) ;
92+ const success = await createLicenseFiles ( licenseKey ) ;
93+ if ( ! success ) {
94+ console . log ( chalk . red ( '\nFailed to setup license configuration. Continuing without a license.' ) ) ;
95+ licenseKey = null ;
96+ }
97+ }
98+ }
99+
44100 // Get available content types
45101 const contentTypes = getContentTypes ( ) ;
46102
@@ -58,9 +114,9 @@ export async function install() {
58114
59115 // Enable Webtools for selected content types
60116 if ( selectedContentTypes . length > 0 ) {
61- console . log ( chalk . blue ( '\nEnabling Webtools for selected content types...' ) ) ;
117+ console . log ( `\n ${ chalk . cyan ( '●' ) } Enabling Webtools for selected content types...` ) ;
62118
63- const results = selectedContentTypes . map ( ( contentType ) => {
119+ selectedContentTypes . map ( ( contentType ) => {
64120 const success = enableWebtoolsForContentType ( contentType ) ;
65121 if ( success ) {
66122 console . log ( chalk . green ( `✓ Enabled Webtools for ${ contentType } ` ) ) ;
@@ -70,9 +126,6 @@ export async function install() {
70126 console . log ( chalk . red ( `✗ Failed to enable Webtools for ${ contentType } ` ) ) ;
71127 return false ;
72128 } ) ;
73-
74- const successCount = results . filter ( Boolean ) . length ;
75- console . log ( chalk . blue ( `\nEnabled Webtools for ${ successCount } of ${ selectedContentTypes . length } content types.` ) ) ;
76129 }
77130 }
78131
@@ -86,6 +139,9 @@ export async function install() {
86139 allAddons = [ ...availableAddons , ...premiumAddons ] ;
87140 }
88141
142+ // New line
143+ console . log ( '' ) ;
144+
89145 // Let user select addons
90146 const selectedAddons = await checkbox ( {
91147 message : 'Select addons to install:' ,
@@ -109,13 +165,13 @@ export async function install() {
109165
110166 // Install all packages at once
111167 if ( packagesToInstall . length > 0 ) {
112- console . log ( chalk . blue ( '\nInstalling packages...' ) ) ;
168+ console . log ( `\n ${ chalk . cyan ( '●' ) } Installing packages...\n` ) ;
113169
114170 const success = installPackage ( packagesToInstall . join ( ' ' ) ) ;
115171 if ( success ) {
116- console . log ( chalk . green ( `✓ Installed ${ packagesToInstall . length } packages successfully` ) ) ;
172+ console . log ( chalk . green ( `\n ✓ Installed ${ packagesToInstall . length } packages successfully` ) ) ;
117173 } else {
118- console . log ( chalk . red ( '✗ Failed to install packages. Aborting installation.' ) ) ;
174+ console . log ( chalk . red ( '\n ✗ Failed to install packages. Aborting installation.' ) ) ;
119175 return ;
120176 }
121177 }
0 commit comments