@@ -34,6 +34,7 @@ import {
3434 createEnvironmentVariableGroup ,
3535 getEnvironmentVariables ,
3636 createEnvironmentVariable ,
37+ uploadEnvironmentVariablesFromFile ,
3738 getEnterpriseProfiles ,
3839 getEnterpriseAppVersions ,
3940 publishEnterpriseAppVersion ,
@@ -68,6 +69,7 @@ import {
6869 getPublishProfileDetailById ,
6970 getPublishVariableGroups ,
7071 getPublishVariableListByGroupId ,
72+ uploadPublishEnvironmentVariablesFromFile ,
7173 deletePublishProfile ,
7274 renamePublishProfile ,
7375 getAppVersions ,
@@ -453,6 +455,39 @@ const handlePublishCommand = async (command: ProgramCommand, params: any) => {
453455 fullCommandName : command . fullCommandName ,
454456 data : variables . variables ,
455457 } ) ;
458+ } else if ( command . fullCommandName === `${ PROGRAM_NAME } -publish-variable-group-upload` ) {
459+ const spinner = createOra ( 'Loading environment variables from JSON file...' ) . start ( ) ;
460+ try {
461+ if ( ! params . filePath ) {
462+ spinner . fail ( 'JSON file path is required' ) ;
463+ process . exit ( 1 ) ;
464+ }
465+
466+ const expandedPath = path . resolve ( params . filePath . replace ( '~' , os . homedir ( ) ) ) ;
467+
468+ if ( ! fs . existsSync ( expandedPath ) ) {
469+ spinner . fail ( 'File not found' ) ;
470+ process . exit ( 1 ) ;
471+ }
472+
473+ try {
474+ const fileContent = fs . readFileSync ( expandedPath , 'utf8' ) ;
475+ JSON . parse ( fileContent ) ;
476+ } catch ( err ) {
477+ spinner . fail ( 'Invalid file' ) ;
478+ process . exit ( 1 ) ;
479+ }
480+
481+ params . filePath = expandedPath ;
482+
483+ const responseData = await uploadPublishEnvironmentVariablesFromFile ( params as any ) ;
484+ if ( responseData ) {
485+ spinner . succeed ( 'Environment variables uploaded successfully' ) ;
486+ }
487+ } catch ( e ) {
488+ spinner . fail ( 'Failed to upload environment variables' ) ;
489+ throw e ;
490+ }
456491 } else if ( command . fullCommandName === `${ PROGRAM_NAME } -publish-variable-group-download` ) {
457492 const spinner = createOra ( 'Downloading publish environment variables...' ) . start ( ) ;
458493 try {
@@ -514,15 +549,15 @@ const handlePublishCommand = async (command: ProgramCommand, params: any) => {
514549 fullCommandName : command . fullCommandName ,
515550 data : appVersions ,
516551 } ) ;
517- } else if ( command . fullCommandName === `${ PROGRAM_NAME } -publish-profile-version-view` ) {
552+ } else if ( command . fullCommandName === `${ PROGRAM_NAME } -publish-profile-version-view` ) {
518553 const spinner = createOra ( 'Fetching...' ) . start ( ) ;
519554 const appVersion = await getAppVersionDetail ( params ) ;
520555 spinner . succeed ( ) ;
521556 commandWriter ( CommandTypes . PUBLISH , {
522557 fullCommandName : command . fullCommandName ,
523558 data : appVersion ,
524559 } ) ;
525- } else if ( command . fullCommandName === `${ PROGRAM_NAME } -publish-profile-version-update-release-note` ) {
560+ } else if ( command . fullCommandName === `${ PROGRAM_NAME } -publish-profile-version-update-release-note` ) {
526561 const spinner = createOra ( 'Try to update relase note of the app version' ) . start ( ) ;
527562 try {
528563 await setAppVersionReleaseNote ( params ) ;
@@ -531,15 +566,15 @@ const handlePublishCommand = async (command: ProgramCommand, params: any) => {
531566 spinner . fail ( 'Update failed' ) ;
532567 throw e ;
533568 }
534- } else if ( command . fullCommandName === `${ PROGRAM_NAME } -publish-active-list` ) {
569+ } else if ( command . fullCommandName === `${ PROGRAM_NAME } -publish-active-list` ) {
535570 const spinner = createOra ( 'Fetching...' ) . start ( ) ;
536571 const responseData = await getActivePublishes ( ) ;
537572 spinner . succeed ( ) ;
538573 commandWriter ( CommandTypes . PUBLISH , {
539574 fullCommandName : command . fullCommandName ,
540575 data : responseData ,
541576 } ) ;
542- } else if ( command . fullCommandName === `${ PROGRAM_NAME } -publish-view` ) {
577+ } else if ( command . fullCommandName === `${ PROGRAM_NAME } -publish-view` ) {
543578 const spinner = createOra ( 'Fetching...' ) . start ( ) ;
544579 const responseData = await getPublisDetailById ( params ) ;
545580 spinner . succeed ( ) ;
@@ -669,6 +704,41 @@ const handleBuildCommand = async (command: ProgramCommand, params:any) => {
669704 fullCommandName : command . fullCommandName ,
670705 data : { ...responseData , name : params . name } ,
671706 } ) ;
707+ } else if ( command . fullCommandName === `${ PROGRAM_NAME } -build-variable-group-upload` ) {
708+ const spinner = createOra ( 'Loading environment variables from JSON file...' ) . start ( ) ;
709+ try {
710+ if ( ! params . filePath ) {
711+ spinner . fail ( 'JSON file path is required' ) ;
712+ process . exit ( 1 ) ;
713+ }
714+
715+ const expandedPath = path . resolve ( params . filePath . replace ( '~' , os . homedir ( ) ) ) ;
716+
717+ if ( ! fs . existsSync ( expandedPath ) ) {
718+ spinner . fail ( 'File not found' ) ;
719+ process . exit ( 1 ) ;
720+ }
721+
722+ try {
723+ const fileContent = fs . readFileSync ( expandedPath , 'utf8' ) ;
724+ JSON . parse ( fileContent ) ;
725+ } catch ( err ) {
726+ spinner . fail ( 'Invalid file' ) ;
727+ process . exit ( 1 ) ;
728+ }
729+
730+ params . filePath = expandedPath ;
731+
732+ const responseData = await uploadEnvironmentVariablesFromFile ( params as any ) ;
733+ spinner . succeed ( 'Environment variables uploaded successfully' ) ;
734+ commandWriter ( CommandTypes . BUILD , {
735+ fullCommandName : command . fullCommandName ,
736+ data : responseData ,
737+ } ) ;
738+ } catch ( e ) {
739+ spinner . fail ( 'Failed to upload environment variables' ) ;
740+ throw e ;
741+ }
672742 } else if ( command . fullCommandName === `${ PROGRAM_NAME } -build-variable-view` ) {
673743 const spinner = createOra ( 'Fetching...' ) . start ( ) ;
674744 const responseData = await getEnvironmentVariables ( params ) ;
0 commit comments