@@ -7,14 +7,16 @@ import { startShell } from '../src/commands/shell.js';
77import { PROJECT_NAME , getLatestVersion } from '../src/commons.js' ;
88import { appInfo , createApp , listApps , deleteApp , updateApp } from '../src/commands/apps.js' ;
99import inquirer from 'inquirer' ;
10- import { initProfileModule } from '../src/modules/ProfileModule.js' ;
10+ import { initProfileModule , getProfileModule } from '../src/modules/ProfileModule.js' ;
1111import { initPuterModule } from '../src/modules/PuterModule.js' ;
1212import { createSite , infoSite , listSites , deleteSite } from '../src/commands/sites.js' ;
1313
1414async function main ( ) {
1515 initProfileModule ( ) ;
1616 initPuterModule ( ) ;
1717
18+ const profileModule = getProfileModule ( ) ;
19+
1820 const version = await getLatestVersion ( PROJECT_NAME ) ;
1921
2022 const program = new Command ( ) ;
@@ -60,6 +62,7 @@ async function main() {
6062 . description ( 'List all your apps' )
6163 . argument ( '[period]' , 'period: today, yesterday, 7d, 30d, this_month, last_month' )
6264 . action ( async ( period ) => {
65+ await profileModule . checkLogin ( ) ;
6366 await listApps ( {
6467 statsPeriod : period || 'all'
6568 } ) ;
@@ -75,6 +78,7 @@ async function main() {
7578 . description ( 'Get application information' )
7679 . argument ( '<app_name>' , 'Name of the application' )
7780 . action ( async ( app_name ) => {
81+ await profileModule . checkLogin ( ) ;
7882 await appInfo ( [ app_name ] ) ;
7983 process . exit ( 0 ) ;
8084 } ) ;
@@ -86,6 +90,7 @@ async function main() {
8690 . argument ( '<remote_dir>' , 'Remote directory URL' )
8791 . action ( async ( name , remote_dir ) => {
8892 try {
93+ await profileModule . checkLogin ( ) ;
8994 await createApp ( {
9095 name : name ,
9196 directory : remote_dir || '' ,
@@ -104,6 +109,7 @@ async function main() {
104109 . argument ( '<name>' , 'Name of the application' )
105110 . argument ( '[dir]' , 'Directory path' , '.' )
106111 . action ( async ( name , dir ) => {
112+ await profileModule . checkLogin ( ) ;
107113 await updateApp ( [ name , dir ] ) ;
108114 process . exit ( 0 ) ;
109115 } ) ;
@@ -114,6 +120,7 @@ async function main() {
114120 . argument ( '<name>' , 'Name of the application' )
115121 . option ( '-f, --force' , 'Force deletion without confirmation' )
116122 . action ( async ( name , options ) => {
123+ await profileModule . checkLogin ( ) ;
117124 let shouldDelete = options . force ;
118125
119126 if ( ! shouldDelete ) {
@@ -140,6 +147,7 @@ async function main() {
140147 . command ( 'sites' )
141148 . description ( 'List sites and subdomains' )
142149 . action ( async ( ) => {
150+ await profileModule . checkLogin ( ) ;
143151 await listSites ( ) ;
144152 process . exit ( 0 ) ;
145153 } ) ;
@@ -153,6 +161,7 @@ async function main() {
153161 . description ( 'Get site information by UID' )
154162 . argument ( '<site_uid>' , 'Site UID' )
155163 . action ( async ( site_uid ) => {
164+ await profileModule . checkLogin ( ) ;
156165 await infoSite ( [ site_uid ] ) ;
157166 process . exit ( 0 ) ;
158167 } ) ;
@@ -164,6 +173,7 @@ async function main() {
164173 . argument ( '[dir]' , 'Directory path' )
165174 . option ( '--subdomain <name>' , 'Subdomain name' )
166175 . action ( async ( app_name , dir , options ) => {
176+ await profileModule . checkLogin ( ) ;
167177 const args = [ app_name ] ;
168178 if ( dir ) args . push ( dir ) ;
169179 if ( options . subdomain ) args . push ( `--subdomain=${ options . subdomain } ` )
@@ -178,6 +188,7 @@ async function main() {
178188 . argument ( '[local_dir]' , 'Local directory path' )
179189 . argument ( '[subdomain]' , 'Deployment subdomain (<subdomain>.puter.site)' )
180190 . action ( async ( local_dir , subdomain ) => {
191+ await profileModule . checkLogin ( ) ;
181192 if ( ! local_dir ) {
182193 const answer = await inquirer . prompt ( [
183194 {
@@ -211,6 +222,7 @@ async function main() {
211222 . argument ( '<uid>' , 'Site UID' )
212223 . option ( '-f, --force' , 'Force deletion without confirmation' )
213224 . action ( async ( uid , options ) => {
225+ await profileModule . checkLogin ( ) ;
214226 let shouldDelete = options . force ;
215227
216228 if ( ! shouldDelete ) {
0 commit comments