@@ -12,7 +12,7 @@ const provider = require('simplify-sdk/provider');
1212const readlineSync = require ( 'readline-sync' ) ;
1313const { options } = require ( 'yargs' ) ;
1414const { authenticate, registerUser, confirmRegistration, getCurrentSession, userSignOut } = require ( './cognito' )
15-
15+ const PLAN_VERSIONS = { "BASIC" : "Community" , "STANDARD" : "Business" , "PREMIUM" : "Enterprise" }
1616var functionMeta = { lashHash256 : null }
1717const opName = `executeCLI`
1818const CGREEN = '\x1b[32m'
@@ -473,7 +473,7 @@ const printListingDialog = function (options, prompt) {
473473 const stackList = fs . existsSync ( stackConfigFile ) ? JSON . parse ( fs . readFileSync ( stackConfigFile ) ) : { }
474474 let tableData = [ ]
475475 if ( Object . keys ( stackList ) . length > 0 ) {
476- console . log ( `\n * ${ prompt ? prompt : `Listing installed components for ${ CNOTIF } ${ envName || process . env . DEPLOYMENT_ENV } ${ CDONE } environment \n` } ` )
476+ console . log ( `\n - ${ prompt ? prompt : `Listing installed components for ${ CNOTIF } ${ envName || process . env . DEPLOYMENT_ENV } ${ CDONE } environment \n` } ` )
477477 Object . keys ( stackList ) . map ( ( stackName , idx ) => {
478478 tableData . push ( {
479479 Index : idx + 1 ,
@@ -487,7 +487,7 @@ const printListingDialog = function (options, prompt) {
487487 } )
488488 utilities . printTableWithJSON ( tableData )
489489 } else {
490- console . log ( `\n * Listing installed components for ${ CNOTIF } ${ envName || process . env . DEPLOYMENT_ENV } ${ CDONE } environment: (empty) \n` )
490+ console . log ( `\n - Listing installed components for ${ CNOTIF } ${ envName || process . env . DEPLOYMENT_ENV } ${ CDONE } environment: (empty) \n` )
491491 }
492492 return tableData
493493}
@@ -523,7 +523,7 @@ const showAvailableStacks = (options, promptDescription) => {
523523 let stackType = ""
524524 let indexOfTemplate = 0
525525 let tableStackData = [ ]
526- console . log ( `\n * ${ promptDescription } \n` )
526+ console . log ( `\n - ${ promptDescription } \n` )
527527 getDirectories ( path . resolve ( '.' ) ) . map ( ( template ) => {
528528 const excludeFolders = [ ".simplify" , ".git" , ".github" , "dist" , "node_modules" , "output" ] . indexOf ( template ) == - 1 ? false : true
529529 if ( ! excludeFolders && ! template . startsWith ( '.' ) && ! template . startsWith ( '_' ) ) {
@@ -583,6 +583,25 @@ var optCMD = (argv._.length > 1 ? argv._[1] : undefined)
583583var cmdArg = argv [ 'stack' ] || argv [ 'function' ] || optCMD
584584var cmdType = cmdArg ? fs . existsSync ( path . resolve ( argv . location , cmdArg , "template.yaml" ) ) ? "CF-Stack" : "Function" : undefined
585585
586+ const showSubscriptionPlan = function ( userSession ) {
587+ const currentPlan = ( userSession . getIdToken ( ) . payload [ `subscription` ] || 'Basic' )
588+ const currentVersion = PLAN_VERSIONS [ currentPlan . toUpperCase ( ) ] || 'Community'
589+ console . log ( `\n` , ` * ${ CPROMPT } Welcome back${ CRESET } : ${ userSession . getIdToken ( ) . payload [ `name` ] } ` )
590+ console . log ( ` * ${ CPROMPT } Subscription${ CRESET } : ${ CDONE } ${ currentPlan } ${ CRESET } Plan - ${ currentVersion } Version` )
591+ if ( currentPlan . toUpperCase ( ) == 'BASIC' ) {
592+ console . log ( ` * ${ CGREEN } Change to standard plan with 10$ monthly for advanced resource${ CRESET } : simplify-cli upgrade --standard` )
593+ console . log ( ` * ${ CRESET } Or upgrade to premium plan with 99$ monthly for CodeMe support${ CRESET } : simplify-cli upgrade --premium` )
594+ }
595+ if ( currentPlan . toUpperCase ( ) == 'STANDARD' ) {
596+ console . log ( ` * ${ CRESET } Change to basic plan (FREE) with 0$ monthly for basic resource${ CRESET } : simplify-cli upgrade --basic` )
597+ console . log ( ` * ${ CGREEN } Or upgrade to premium plan with 99$ monthly for CodeMe support${ CRESET } : simplify-cli upgrade --premium` )
598+ }
599+ if ( currentPlan . toUpperCase ( ) == 'PREMIUM' ) {
600+ console . log ( ` * ${ CRESET } Change to basic plan (FREE) with 0$ monthly for basic resource${ CRESET } : simplify-cli upgrade --basic` )
601+ console . log ( ` * ${ CRESET } Change to standard plan with 10$ monthly for advanced resource${ CRESET } : simplify-cli upgrade --standard` )
602+ }
603+ }
604+
586605const processCLI = function ( cmdRun , session ) {
587606 if ( cmdRun === "DEPLOY" ) {
588607 if ( cmdArg !== undefined ) {
@@ -644,9 +663,7 @@ const processCLI = function (cmdRun, session) {
644663 const username = readlineSync . questionEMail ( ` - ${ CPROMPT } Your identity${ CRESET } : ` , { limitMessage : " * Your login email is invalid." } )
645664 const password = readlineSync . question ( ` - ${ CPROMPT } Your password${ CRESET } : ` , { hideEchoBack : true } )
646665 authenticate ( username , password ) . then ( function ( userSession ) {
647- console . log ( `\n` , ` * ${ CPROMPT } Welcome back${ CRESET } : ${ userSession . getIdToken ( ) . payload [ `name` ] } ` )
648- console . log ( ` * ${ CPROMPT } Subscription${ CRESET } : ${ userSession . getIdToken ( ) . payload [ `subscription` ] || 'Basic Plan - Community Version' } ` )
649- console . log ( ` * ${ CGREEN } Upgrade to premium plan with 100$ monthly for CodeMe support${ CRESET } : simplify-cli upgrade` , `\n` )
666+ showSubscriptionPlan ( userSession )
650667 } ) . catch ( error => console . error ( error ) )
651668 } else if ( cmdRun === "REGISTER" ) {
652669 const fullname = readlineSync . question ( ` - ${ CPROMPT } What is your name${ CRESET } : ` , { limitMessage : " * Your name is invalid." } )
@@ -717,6 +734,7 @@ if (!fs.existsSync(path.resolve(argv.config || 'config.json'))) {
717734 if ( [ "LOGIN" , "REGISTER" ] . indexOf ( cmdOPS ) == - 1 ) {
718735 getCurrentSession ( ) . then ( session => {
719736 if ( session && session . isValid ( ) ) {
737+ showSubscriptionPlan ( session )
720738 processCLI ( cmdOPS , session )
721739 } else {
722740 console . log ( `${ CPROMPT } Session is invalid${ CRESET } . Please re-login.` )
0 commit comments