@@ -48,6 +48,7 @@ import {
48
48
import { loadSchema , JSONSchema } from '@app-config/schema' ;
49
49
import { generateTypeFiles } from '@app-config/generate' ;
50
50
import { validateAllConfigVariants } from './validation' ;
51
+ import { loadMetaConfigLazy } from '@app-config/meta' ;
51
52
52
53
enum OptionGroups {
53
54
Options = 'Options:' ,
@@ -318,6 +319,21 @@ function fileTypeForFormatOption(option: string): FileType {
318
319
}
319
320
}
320
321
322
+ async function loadEnvironmentOptions ( opts : {
323
+ environmentOverride ?: string ;
324
+ environmentVariableName ?: string ;
325
+ } ) {
326
+ const {
327
+ value : { environmentAliases , environmentSourceNames } ,
328
+ } = await loadMetaConfigLazy ( ) ;
329
+
330
+ return asEnvOptions (
331
+ opts . environmentOverride ,
332
+ environmentAliases ,
333
+ opts . environmentVariableName ?? environmentSourceNames ,
334
+ ) ;
335
+ }
336
+
321
337
export const cli = yargs
322
338
. scriptName ( 'app-config' )
323
339
. wrap ( Math . max ( yargs . terminalWidth ( ) - 5 , 80 ) )
@@ -583,11 +599,7 @@ export const cli = yargs
583
599
} ,
584
600
} ,
585
601
async ( opts ) => {
586
- const environmentOptions = asEnvOptions (
587
- opts . environmentOverride ,
588
- undefined ,
589
- opts . environmentVariableName ,
590
- ) ;
602
+ const environmentOptions = await loadEnvironmentOptions ( opts ) ;
591
603
592
604
const myKey = await loadPublicKeyLazy ( ) ;
593
605
const privateKey = await loadPrivateKeyLazy ( ) ;
@@ -615,11 +627,7 @@ export const cli = yargs
615
627
} ,
616
628
} ,
617
629
async ( opts ) => {
618
- const environmentOptions = asEnvOptions (
619
- opts . environmentOverride ,
620
- undefined ,
621
- opts . environmentVariableName ,
622
- ) ;
630
+ const environmentOptions = await loadEnvironmentOptions ( opts ) ;
623
631
624
632
const keys = await loadSymmetricKeys ( undefined , environmentOptions ) ;
625
633
const teamMembers = await loadTeamMembersLazy ( environmentOptions ) ;
@@ -701,11 +709,7 @@ export const cli = yargs
701
709
} ,
702
710
} ,
703
711
async ( opts ) => {
704
- const environmentOptions = asEnvOptions (
705
- opts . environmentOverride ,
706
- undefined ,
707
- opts . environmentVariableName ,
708
- ) ;
712
+ const environmentOptions = await loadEnvironmentOptions ( opts ) ;
709
713
710
714
logger . info ( 'Creating a new trusted CI encryption key' ) ;
711
715
@@ -754,11 +758,7 @@ export const cli = yargs
754
758
} ,
755
759
} ,
756
760
async ( opts ) => {
757
- const environmentOptions = asEnvOptions (
758
- opts . environmentOverride ,
759
- undefined ,
760
- opts . environmentVariableName ,
761
- ) ;
761
+ const environmentOptions = await loadEnvironmentOptions ( opts ) ;
762
762
763
763
const key = await loadKey ( await readFile ( opts . keyPath ) ) ;
764
764
const privateKey = await loadPrivateKeyLazy ( ) ;
@@ -792,12 +792,7 @@ export const cli = yargs
792
792
} ,
793
793
} ,
794
794
async ( opts ) => {
795
- const environmentOptions = asEnvOptions (
796
- opts . environmentOverride ,
797
- undefined ,
798
- opts . environmentVariableName ,
799
- ) ;
800
-
795
+ const environmentOptions = await loadEnvironmentOptions ( opts ) ;
801
796
const privateKey = await loadPrivateKeyLazy ( ) ;
802
797
803
798
// TODO: by default, untrust for all envs?
@@ -828,11 +823,7 @@ export const cli = yargs
828
823
} ,
829
824
} ,
830
825
async ( opts ) => {
831
- const environmentOptions = asEnvOptions (
832
- opts . environmentOverride ,
833
- undefined ,
834
- opts . environmentVariableName ,
835
- ) ;
826
+ const environmentOptions = await loadEnvironmentOptions ( opts ) ;
836
827
837
828
shouldUseSecretAgent ( opts . agent ) ;
838
829
@@ -900,11 +891,7 @@ export const cli = yargs
900
891
} ,
901
892
} ,
902
893
async ( opts ) => {
903
- const environmentOptions = asEnvOptions (
904
- opts . environmentOverride ,
905
- undefined ,
906
- opts . environmentVariableName ,
907
- ) ;
894
+ const environmentOptions = await loadEnvironmentOptions ( opts ) ;
908
895
909
896
shouldUseSecretAgent ( opts . agent ) ;
910
897
0 commit comments