11import fs from "fs" ;
2+ import path from "path" ;
23import { parse as parseDotenv } from "dotenv" ;
34import chalk from "chalk" ;
45import inquirer from "inquirer" ;
@@ -25,7 +26,9 @@ import {
2526 questionsPushBuckets ,
2627 questionsPushTeams ,
2728 questionsPushFunctions ,
29+ questionsPushFunctionsCode ,
2830 questionsPushSites ,
31+ questionsPushSitesCode ,
2932 questionsGetEntrypoint ,
3033 questionsPushCollections ,
3134 questionsPushTables ,
@@ -414,23 +417,23 @@ export class Push {
414417 this . log ( "Applying auth security settings ..." ) ;
415418 await projectsService . updateAuthDuration ( {
416419 projectId,
417- duration : settings . auth . security . duration ,
420+ duration : Number ( settings . auth . security . duration ) ,
418421 } ) ;
419422 await projectsService . updateAuthLimit ( {
420423 projectId,
421- limit : settings . auth . security . limit ,
424+ limit : Number ( settings . auth . security . limit ) ,
422425 } ) ;
423426 await projectsService . updateAuthSessionsLimit ( {
424427 projectId,
425- limit : settings . auth . security . sessionsLimit ,
428+ limit : Number ( settings . auth . security . sessionsLimit ) ,
426429 } ) ;
427430 await projectsService . updateAuthPasswordDictionary ( {
428431 projectId,
429432 enabled : settings . auth . security . passwordDictionary ,
430433 } ) ;
431434 await projectsService . updateAuthPasswordHistory ( {
432435 projectId,
433- limit : settings . auth . security . passwordHistory ,
436+ limit : Number ( settings . auth . security . passwordHistory ) ,
434437 } ) ;
435438 await projectsService . updatePersonalDataCheck ( {
436439 projectId,
@@ -807,6 +810,27 @@ export class Push {
807810 return ;
808811 }
809812
813+ if ( ! func . path ) {
814+ errors . push ( new Error ( `Function '${ func . name } ' has no path configured` ) ) ;
815+ updaterRow . fail ( {
816+ errorMessage : `No path configured for function` ,
817+ } ) ;
818+ return ;
819+ }
820+
821+ if (
822+ ! fs . existsSync ( func . path ) ||
823+ fs . readdirSync ( func . path ) . length === 0
824+ ) {
825+ errors . push (
826+ new Error ( `Deployment not found or empty at path: ${ func . path } ` ) ,
827+ ) ;
828+ updaterRow . fail ( {
829+ errorMessage : `path not found or empty: ${ path . relative ( process . cwd ( ) , path . resolve ( func . path ) ) } ` ,
830+ } ) ;
831+ return ;
832+ }
833+
810834 try {
811835 updaterRow . update ( { status : "Pushing" } ) . replaceSpinner ( SPINNER_DOTS ) ;
812836 const functionsServiceDeploy = await getFunctionsService (
@@ -838,7 +862,7 @@ export class Push {
838862 switch ( e . code ) {
839863 case "ENOENT" :
840864 updaterRow . fail ( {
841- errorMessage : "Not found in the current directory. Skipping..." ,
865+ errorMessage : `Deployment not found at path: ${ path . resolve ( func . path ) } ` ,
842866 } ) ;
843867 break ;
844868 default :
@@ -1145,6 +1169,27 @@ export class Push {
11451169 return ;
11461170 }
11471171
1172+ if ( ! site . path ) {
1173+ errors . push ( new Error ( `Site '${ site . name } ' has no path configured` ) ) ;
1174+ updaterRow . fail ( {
1175+ errorMessage : `No path configured for site` ,
1176+ } ) ;
1177+ return ;
1178+ }
1179+
1180+ if (
1181+ ! fs . existsSync ( site . path ) ||
1182+ fs . readdirSync ( site . path ) . length === 0
1183+ ) {
1184+ errors . push (
1185+ new Error ( `Deployment not found or empty at path: ${ site . path } ` ) ,
1186+ ) ;
1187+ updaterRow . fail ( {
1188+ errorMessage : `path not found or empty: ${ path . relative ( process . cwd ( ) , path . resolve ( site . path ) ) } ` ,
1189+ } ) ;
1190+ return ;
1191+ }
1192+
11481193 try {
11491194 updaterRow . update ( { status : "Pushing" } ) . replaceSpinner ( SPINNER_DOTS ) ;
11501195 const sitesServiceDeploy = await getSitesService ( this . projectClient ) ;
@@ -1174,7 +1219,7 @@ export class Push {
11741219 switch ( e . code ) {
11751220 case "ENOENT" :
11761221 updaterRow . fail ( {
1177- errorMessage : "Not found in the current directory. Skipping..." ,
1222+ errorMessage : `Deployment not found at path: ${ path . resolve ( site . path ) } ` ,
11781223 } ) ;
11791224 break ;
11801225 default :
@@ -1593,13 +1638,47 @@ const pushResources = async ({
15931638 if ( cliConfig . all ) {
15941639 checkDeployConditions ( localConfig ) ;
15951640
1641+ const functions = localConfig . getFunctions ( ) ;
1642+ let allowFunctionsCodePush : boolean | null =
1643+ cliConfig . force === true ? true : null ;
1644+ if ( functions . length > 0 && allowFunctionsCodePush === null ) {
1645+ const codeAnswer = await inquirer . prompt ( questionsPushFunctionsCode ) ;
1646+ allowFunctionsCodePush = codeAnswer . override ;
1647+ }
1648+
1649+ const sites = localConfig . getSites ( ) ;
1650+ let allowSitesCodePush : boolean | null =
1651+ cliConfig . force === true ? true : null ;
1652+ if ( sites . length > 0 && allowSitesCodePush === null ) {
1653+ const codeAnswer = await inquirer . prompt ( questionsPushSitesCode ) ;
1654+ allowSitesCodePush = codeAnswer . override ;
1655+ }
1656+
15961657 const pushInstance = await createPushInstance ( ) ;
1597- const config = localConfig . getProject ( ) as ConfigType ;
1658+ const project = localConfig . getProject ( ) ;
1659+ const config : ConfigType = {
1660+ projectId : project . projectId ?? "" ,
1661+ projectName : project . projectName ,
1662+ settings : project . projectSettings ,
1663+ functions,
1664+ sites,
1665+ collections : localConfig . getCollections ( ) ,
1666+ databases : localConfig . getDatabases ( ) ,
1667+ tables : localConfig . getTables ( ) ,
1668+ tablesDB : localConfig . getTablesDBs ( ) ,
1669+ buckets : localConfig . getBuckets ( ) ,
1670+ teams : localConfig . getTeams ( ) ,
1671+ topics : localConfig . getMessagingTopics ( ) ,
1672+ } ;
15981673
15991674 await pushInstance . pushResources ( config , {
1675+ all : cliConfig . all ,
16001676 skipDeprecated,
1601- functionOptions : { code : true , withVariables : false } ,
1602- siteOptions : { code : true , withVariables : false } ,
1677+ functionOptions : {
1678+ code : allowFunctionsCodePush === true ,
1679+ withVariables : false ,
1680+ } ,
1681+ siteOptions : { code : allowSitesCodePush === true , withVariables : false } ,
16031682 } ) ;
16041683 } else {
16051684 const actions : Record < string , ( options ?: any ) => Promise < void > > = {
@@ -1763,12 +1842,20 @@ const pushSite = async ({
17631842 return ;
17641843 }
17651844
1845+ let allowCodePush : boolean | null = cliConfig . force === true ? true : null ;
1846+ if ( code !== false && allowCodePush === null ) {
1847+ const codeAnswer = await inquirer . prompt ( questionsPushSitesCode ) ;
1848+ allowCodePush = codeAnswer . override ;
1849+ }
1850+
1851+ const shouldPushCode = code !== false && allowCodePush === true ;
1852+
17661853 log ( "Pushing sites ..." ) ;
17671854
17681855 const pushInstance = await createPushInstance ( ) ;
17691856 const result = await pushInstance . pushSites ( sites , {
17701857 async : asyncDeploy ,
1771- code,
1858+ code : shouldPushCode ,
17721859 withVariables,
17731860 } ) ;
17741861
@@ -1883,12 +1970,20 @@ const pushFunction = async ({
18831970 return ;
18841971 }
18851972
1973+ let allowCodePush : boolean | null = cliConfig . force === true ? true : null ;
1974+ if ( code !== false && allowCodePush === null ) {
1975+ const codeAnswer = await inquirer . prompt ( questionsPushFunctionsCode ) ;
1976+ allowCodePush = codeAnswer . override ;
1977+ }
1978+
1979+ const shouldPushCode = code !== false && allowCodePush === true ;
1980+
18861981 log ( "Pushing functions ..." ) ;
18871982
18881983 const pushInstance = await createPushInstance ( ) ;
18891984 const result = await pushInstance . pushFunctions ( functions , {
18901985 async : asyncDeploy ,
1891- code,
1986+ code : shouldPushCode ,
18921987 withVariables,
18931988 } ) ;
18941989
0 commit comments