@@ -459,17 +459,8 @@ export interface InitConfigInputs {
459
459
logger : Logger ;
460
460
}
461
461
462
- type GetDefaultConfigInputs = Omit <
463
- InitConfigInputs ,
464
- "configFile" | "configInput"
465
- > ;
466
-
467
- type LoadConfigInputs = Omit < InitConfigInputs , "configInput" > & {
468
- configFile : string ;
469
- } ;
470
-
471
462
/**
472
- * Get the default config for when the user has not supplied one .
463
+ * Get the default config, populated without user configuration file .
473
464
*/
474
465
export async function getDefaultConfig ( {
475
466
languagesInput,
@@ -490,7 +481,7 @@ export async function getDefaultConfig({
490
481
githubVersion,
491
482
features,
492
483
logger,
493
- } : GetDefaultConfigInputs ) : Promise < Config > {
484
+ } : InitConfigInputs ) : Promise < Config > {
494
485
const languages = await getLanguages (
495
486
codeql ,
496
487
languagesInput ,
@@ -562,91 +553,6 @@ async function downloadCacheWithTime(
562
553
return { trapCaches, trapCacheDownloadTime } ;
563
554
}
564
555
565
- /**
566
- * Load the config from the given file.
567
- */
568
- async function loadConfig ( {
569
- languagesInput,
570
- queriesInput,
571
- qualityQueriesInput,
572
- packsInput,
573
- buildModeInput,
574
- configFile,
575
- dbLocation,
576
- trapCachingEnabled,
577
- dependencyCachingEnabled,
578
- debugMode,
579
- debugArtifactName,
580
- debugDatabaseName,
581
- repository,
582
- tempDir,
583
- codeql,
584
- workspacePath,
585
- sourceRoot,
586
- githubVersion,
587
- apiDetails,
588
- features,
589
- logger,
590
- } : LoadConfigInputs ) : Promise < Config > {
591
- const parsedYAML = await loadUserConfig (
592
- configFile ,
593
- workspacePath ,
594
- apiDetails ,
595
- tempDir ,
596
- ) ;
597
-
598
- const languages = await getLanguages (
599
- codeql ,
600
- languagesInput ,
601
- repository ,
602
- logger ,
603
- ) ;
604
-
605
- const buildMode = await parseBuildModeInput (
606
- buildModeInput ,
607
- languages ,
608
- features ,
609
- logger ,
610
- ) ;
611
-
612
- const augmentationProperties = await calculateAugmentation (
613
- codeql ,
614
- repository ,
615
- features ,
616
- packsInput ,
617
- queriesInput ,
618
- qualityQueriesInput ,
619
- languages ,
620
- sourceRoot ,
621
- buildMode ,
622
- logger ,
623
- ) ;
624
-
625
- const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime (
626
- trapCachingEnabled ,
627
- codeql ,
628
- languages ,
629
- logger ,
630
- ) ;
631
-
632
- return {
633
- languages,
634
- buildMode,
635
- originalUserInput : parsedYAML ,
636
- tempDir,
637
- codeQLCmd : codeql . getPath ( ) ,
638
- gitHubVersion : githubVersion ,
639
- dbLocation : dbLocationOrDefault ( dbLocation , tempDir ) ,
640
- debugMode,
641
- debugArtifactName,
642
- debugDatabaseName,
643
- augmentationProperties,
644
- trapCaches,
645
- trapCacheDownloadTime,
646
- dependencyCachingEnabled : getCachingKind ( dependencyCachingEnabled ) ,
647
- } ;
648
- }
649
-
650
556
async function loadUserConfig (
651
557
configFile : string ,
652
558
workspacePath : string ,
@@ -1065,8 +971,6 @@ function userConfigFromActionPath(tempDir: string): string {
1065
971
* a default config. The parsed config is then stored to a known location.
1066
972
*/
1067
973
export async function initConfig ( inputs : InitConfigInputs ) : Promise < Config > {
1068
- let config : Config ;
1069
-
1070
974
const { logger, tempDir } = inputs ;
1071
975
1072
976
// if configInput is set, it takes precedence over configFile
@@ -1081,15 +985,22 @@ export async function initConfig(inputs: InitConfigInputs): Promise<Config> {
1081
985
logger . debug ( `Using config from action input: ${ inputs . configFile } ` ) ;
1082
986
}
1083
987
1084
- // If no config file was provided create an empty one
988
+ let userConfig : UserConfig = { } ;
1085
989
if ( ! inputs . configFile ) {
1086
990
logger . debug ( "No configuration file was provided" ) ;
1087
- config = await getDefaultConfig ( inputs ) ;
1088
991
} else {
1089
- // Convince the type checker that inputs.configFile is defined.
1090
- config = await loadConfig ( { ...inputs , configFile : inputs . configFile } ) ;
992
+ logger . debug ( `Using configuration file: ${ inputs . configFile } ` ) ;
993
+ userConfig = await loadUserConfig (
994
+ inputs . configFile ,
995
+ inputs . workspacePath ,
996
+ inputs . apiDetails ,
997
+ tempDir ,
998
+ ) ;
1091
999
}
1092
1000
1001
+ const config = await getDefaultConfig ( inputs ) ;
1002
+ config . originalUserInput = userConfig ;
1003
+
1093
1004
// Save the config so we can easily access it again in the future
1094
1005
await saveConfig ( config , logger ) ;
1095
1006
return config ;
0 commit comments